Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,14 +6,32 @@ generator = pipeline(
|
|
| 6 |
model="deepseek-ai/deepseek-coder-1.3b-instruct"
|
| 7 |
)
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
title="Python Coding Assistant",
|
| 18 |
description="Ask Python coding questions"
|
| 19 |
)
|
|
|
|
| 6 |
model="deepseek-ai/deepseek-coder-1.3b-instruct"
|
| 7 |
)
|
| 8 |
|
| 9 |
+
SYSTEM_PROMPT = """
|
| 10 |
+
You are an expert Python developer.
|
| 11 |
+
|
| 12 |
+
Always:
|
| 13 |
+
- write clean Python code
|
| 14 |
+
- add comments when useful
|
| 15 |
+
- avoid unnecessary explanations
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
def chat(message, history):
|
| 19 |
+
|
| 20 |
+
prompt = SYSTEM_PROMPT + "\nUser: " + message + "\nAssistant:"
|
| 21 |
+
|
| 22 |
+
result = generator(
|
| 23 |
+
prompt,
|
| 24 |
+
max_new_tokens=200,
|
| 25 |
+
temperature=0.2
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
output = result[0]["generated_text"]
|
| 29 |
+
|
| 30 |
+
return output.split("Assistant:")[-1]
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
demo = gr.ChatInterface(
|
| 34 |
+
fn=chat,
|
| 35 |
title="Python Coding Assistant",
|
| 36 |
description="Ask Python coding questions"
|
| 37 |
)
|