Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,16 +4,19 @@ from transformers import pipeline
|
|
| 4 |
generator = pipeline(
|
| 5 |
"text-generation",
|
| 6 |
model="deepseek-ai/deepseek-coder-1.3b-instruct",
|
|
|
|
| 7 |
clean_up_tokenization_spaces=True
|
| 8 |
)
|
| 9 |
|
| 10 |
SYSTEM_PROMPT = """
|
| 11 |
-
You are
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
-
|
| 15 |
-
-
|
| 16 |
-
-
|
|
|
|
|
|
|
| 17 |
"""
|
| 18 |
|
| 19 |
def chat(message, history):
|
|
@@ -31,7 +34,9 @@ def chat(message, history):
|
|
| 31 |
# Clean tokenizer artifacts
|
| 32 |
output = output.replace("Ċ", "\n").replace("Ġ", " ")
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
demo = gr.ChatInterface(
|
|
|
|
| 4 |
generator = pipeline(
|
| 5 |
"text-generation",
|
| 6 |
model="deepseek-ai/deepseek-coder-1.3b-instruct",
|
| 7 |
+
device_map="auto".
|
| 8 |
clean_up_tokenization_spaces=True
|
| 9 |
)
|
| 10 |
|
| 11 |
SYSTEM_PROMPT = """
|
| 12 |
+
You are a senior Python engineer.
|
| 13 |
+
|
| 14 |
+
When answering:
|
| 15 |
+
- Return clean Python code
|
| 16 |
+
- Follow best practices
|
| 17 |
+
- Keep functions simple
|
| 18 |
+
- Add comments if useful
|
| 19 |
+
- Avoid unnecessary explanations
|
| 20 |
"""
|
| 21 |
|
| 22 |
def chat(message, history):
|
|
|
|
| 34 |
# Clean tokenizer artifacts
|
| 35 |
output = output.replace("Ċ", "\n").replace("Ġ", " ")
|
| 36 |
|
| 37 |
+
code = output.split("Assistant:")[-1]
|
| 38 |
+
|
| 39 |
+
return f"```python\n{code}\n```"
|
| 40 |
|
| 41 |
|
| 42 |
demo = gr.ChatInterface(
|