Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,9 +10,8 @@ from huggingface_hub import InferenceClient
|
|
| 10 |
MODELS = {
|
| 11 |
"Meta LLaMA 3.1 (8B Instruct)": "meta-llama/Llama-3.1-8B-Instruct",
|
| 12 |
"Mistral 7B Instruct": "mistralai/Mistral-7B-Instruct-v0.3",
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
"CoMA (Multilingual)": "Denilah/CoMA"
|
| 16 |
}
|
| 17 |
|
| 18 |
HF_TOKEN = os.getenv("HF_TOKEN") # Set in your Space's Secrets
|
|
@@ -23,7 +22,8 @@ SYSTEM_DEFAULT = (
|
|
| 23 |
"Always prioritize database, API, authentication, routing, migrations, and CRUD logic. "
|
| 24 |
"Provide full backend code scaffolds with files, paths, and commands. "
|
| 25 |
"Only include frontend if required for framework integration "
|
| 26 |
-
"(e.g., Laravel Blade, Django templates).
|
|
|
|
| 27 |
)
|
| 28 |
|
| 29 |
# ---------------------------
|
|
@@ -96,8 +96,7 @@ def get_messages(session_id: int):
|
|
| 96 |
""", (session_id,))
|
| 97 |
rows = cur.fetchall()
|
| 98 |
conn.close()
|
| 99 |
-
|
| 100 |
-
return msgs
|
| 101 |
|
| 102 |
def add_message(session_id: int, role: str, content: str):
|
| 103 |
conn = db()
|
|
@@ -259,7 +258,7 @@ if not labels:
|
|
| 259 |
labels, _ = list_sessions()
|
| 260 |
default_selected = labels[0] if labels else None
|
| 261 |
|
| 262 |
-
with gr.Blocks(title="Backend-Focused
|
| 263 |
gr.HTML("""
|
| 264 |
<style>
|
| 265 |
button {
|
|
@@ -277,7 +276,7 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 277 |
</style>
|
| 278 |
""")
|
| 279 |
|
| 280 |
-
gr.Markdown("## 🗄️
|
| 281 |
|
| 282 |
with gr.Row():
|
| 283 |
with gr.Column(scale=1, min_width=260):
|
|
@@ -301,7 +300,7 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 301 |
interactive=True
|
| 302 |
)
|
| 303 |
|
| 304 |
-
|
| 305 |
system_box = gr.Textbox(
|
| 306 |
value=SYSTEM_DEFAULT,
|
| 307 |
label="System message",
|
|
@@ -345,5 +344,3 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 345 |
|
| 346 |
if __name__ == "__main__":
|
| 347 |
demo.launch()
|
| 348 |
-
|
| 349 |
-
|
|
|
|
| 10 |
MODELS = {
|
| 11 |
"Meta LLaMA 3.1 (8B Instruct)": "meta-llama/Llama-3.1-8B-Instruct",
|
| 12 |
"Mistral 7B Instruct": "mistralai/Mistral-7B-Instruct-v0.3",
|
| 13 |
+
"StarCoder Backend-Focused": "bigcode/starcoderbase",
|
| 14 |
+
"CodeLlama Backend-Focused": "codellama/CodeLlama-7b-Instruct"
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
HF_TOKEN = os.getenv("HF_TOKEN") # Set in your Space's Secrets
|
|
|
|
| 22 |
"Always prioritize database, API, authentication, routing, migrations, and CRUD logic. "
|
| 23 |
"Provide full backend code scaffolds with files, paths, and commands. "
|
| 24 |
"Only include frontend if required for framework integration "
|
| 25 |
+
"(e.g., Laravel Blade, Django templates). "
|
| 26 |
+
"If asked for unrelated frontend/UI tasks, respond politely that you are a backend assistant."
|
| 27 |
)
|
| 28 |
|
| 29 |
# ---------------------------
|
|
|
|
| 96 |
""", (session_id,))
|
| 97 |
rows = cur.fetchall()
|
| 98 |
conn.close()
|
| 99 |
+
return [{"role": role, "content": content} for role, content in rows]
|
|
|
|
| 100 |
|
| 101 |
def add_message(session_id: int, role: str, content: str):
|
| 102 |
conn = db()
|
|
|
|
| 258 |
labels, _ = list_sessions()
|
| 259 |
default_selected = labels[0] if labels else None
|
| 260 |
|
| 261 |
+
with gr.Blocks(title="Backend-Focused CRUD Assistant", theme=gr.themes.Soft()) as demo:
|
| 262 |
gr.HTML("""
|
| 263 |
<style>
|
| 264 |
button {
|
|
|
|
| 276 |
</style>
|
| 277 |
""")
|
| 278 |
|
| 279 |
+
gr.Markdown("## 🗄️ Backend-Focused CRUD Automation — with Persistent History")
|
| 280 |
|
| 281 |
with gr.Row():
|
| 282 |
with gr.Column(scale=1, min_width=260):
|
|
|
|
| 300 |
interactive=True
|
| 301 |
)
|
| 302 |
|
| 303 |
+
gr.Markdown("### ⚙️ Generation Settings")
|
| 304 |
system_box = gr.Textbox(
|
| 305 |
value=SYSTEM_DEFAULT,
|
| 306 |
label="System message",
|
|
|
|
| 344 |
|
| 345 |
if __name__ == "__main__":
|
| 346 |
demo.launch()
|
|
|
|
|
|