ML610 commited on
Commit
67621e9
1 Parent(s): ca52a2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -33,12 +33,8 @@ def generate(
33
  ):
34
  """run model inference, will return a Generator if streaming is true"""
35
 
36
- return llm(
37
- format_prompt(
38
- user_prompt,
39
- ),
40
- **asdict(generation_config),
41
- )
42
 
43
  config = AutoConfig.from_pretrained(
44
  "teknium/Replit-v2-CodeInstruct-3B", context_length=2048
@@ -66,7 +62,7 @@ user_prefix = "[user]: "
66
  assistant_prefix = f"[assistant]:"
67
 
68
  title = "Replit-v2-CodeInstruct-3b-ggml"
69
- description = "This space is an attempt to run the 4 bit quantized version of 'Replit's CodeInstruct 3B' on CPU"
70
 
71
  example_1 = "Write a python script for a function which calculates the factorial of the number inputted by user."
72
  example_2 = "Write a python script which prints 'you are logged in' only if the user inputs a number between 1-10"
@@ -74,7 +70,7 @@ example_2 = "Write a python script which prints 'you are logged in' only if the
74
  examples = [example_1, example_2]
75
 
76
  UI = gr.Interface(
77
- fn=lambda user_prompt: generate(llm, generation_config, user_prompt),
78
  inputs=gr.Textbox(label="user_prompt", placeholder="Ask your queries here...."),
79
  outputs=gr.Textbox(label="Assistant"),
80
  title=title,
 
33
  ):
34
  """run model inference, will return a Generator if streaming is true"""
35
 
36
+ generator = llm(format_prompt(user_prompt), **asdict(generation_config))
37
+ return generator.generated_text
 
 
 
 
38
 
39
  config = AutoConfig.from_pretrained(
40
  "teknium/Replit-v2-CodeInstruct-3B", context_length=2048
 
62
  assistant_prefix = f"[assistant]:"
63
 
64
  title = "Replit-v2-CodeInstruct-3b-ggml"
65
+ description = "This space is an attempt to run the 4 bit quantized version of 'Replit's CodeInstruct 3B' on a CPU"
66
 
67
  example_1 = "Write a python script for a function which calculates the factorial of the number inputted by user."
68
  example_2 = "Write a python script which prints 'you are logged in' only if the user inputs a number between 1-10"
 
70
  examples = [example_1, example_2]
71
 
72
  UI = gr.Interface(
73
+ fn=generate,
74
  inputs=gr.Textbox(label="user_prompt", placeholder="Ask your queries here...."),
75
  outputs=gr.Textbox(label="Assistant"),
76
  title=title,