raghualgt commited on
Commit
9e2903c
·
verified ·
1 Parent(s): f586e35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
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 an expert Python developer.
12
-
13
- Always:
14
- - write clean Python code
15
- - add comments when useful
16
- - avoid unnecessary explanations
 
 
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
- return output.split("Assistant:")[-1]
 
 
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(