miiann commited on
Commit
65dfcfb
·
verified ·
1 Parent(s): 6bf0dc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -1,19 +1,19 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Using a smaller, more stable model
5
  model = pipeline(
6
  "text-generation",
7
- model="bigcode/tiny_starcoder_py", # Very small model for CPU
8
  device="cpu"
9
  )
10
 
11
  def generate_code(prompt):
12
  try:
13
  response = model(
14
- f"# Python Question\n{prompt}\n# Answer\n",
15
  max_new_tokens=80,
16
- temperature=0.2,
17
  do_sample=False
18
  )
19
  return response[0]['generated_text'].split("# Answer\n")[-1]
@@ -24,8 +24,7 @@ demo = gr.Interface(
24
  fn=generate_code,
25
  inputs=gr.Textbox(lines=2, placeholder="Ask about Python..."),
26
  outputs=gr.Code(language="python"),
27
- title="Stable Coding Assistant",
28
- allow_flagging="never"
29
  )
30
 
31
  demo.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Stable configuration for CPU
5
  model = pipeline(
6
  "text-generation",
7
+ model="bigcode/tiny_starcoder_py",
8
  device="cpu"
9
  )
10
 
11
  def generate_code(prompt):
12
  try:
13
  response = model(
14
+ f"# Question\n{prompt}\n# Answer\n",
15
  max_new_tokens=80,
16
+ temperature=0.3,
17
  do_sample=False
18
  )
19
  return response[0]['generated_text'].split("# Answer\n")[-1]
 
24
  fn=generate_code,
25
  inputs=gr.Textbox(lines=2, placeholder="Ask about Python..."),
26
  outputs=gr.Code(language="python"),
27
+ title="Stable Coding Assistant"
 
28
  )
29
 
30
  demo.launch()