andyfe commited on
Commit
d8d22a8
·
1 Parent(s): 7ace03c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -159,20 +159,19 @@ def query(system_prompt, user_prompt, temperature=0.9, max_new_tokens=256, top_p
159
  prompt = f"System: {system_prompt}\nUser: {user_prompt}\n"
160
  print(prompt)
161
  print('-----')
162
- output = client.text_generation(prompt, **generate_kwargs, details=True, return_full_text=False)
163
- print(output)
164
- # stream = client.text_generation(prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
165
- # output = ""
166
-
167
- # for response in stream:
168
- # output += response.token.text
169
-
170
- # for stop_str in STOP_SEQUENCES:
171
- # if output.endswith(stop_str):
172
- # output = output[:-len(stop_str)]
173
- # output = output.rstrip()
174
- # yield output
175
- # yield output
176
  return output
177
 
178
  iface = gr.Interface(
 
159
  prompt = f"System: {system_prompt}\nUser: {user_prompt}\n"
160
  print(prompt)
161
  print('-----')
162
+ #output = client.text_generation(prompt, **generate_kwargs, details=True, return_full_text=False)
163
+ #print(output)
164
+ stream = client.text_generation(prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
165
+ output = ""
166
+ for response in stream:
167
+ output += response.token.text
168
+
169
+ for stop_str in STOP_SEQUENCES:
170
+ if output.endswith(stop_str):
171
+ output = output[:-len(stop_str)]
172
+ output = output.rstrip()
173
+ #yield output
174
+ #yield output
 
175
  return output
176
 
177
  iface = gr.Interface(