gorkemgoknar commited on
Commit
fcfbb80
1 Parent(s): d7ce43f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -32
app.py CHANGED
@@ -90,7 +90,7 @@ HF_TOKEN = os.environ.get("HF_TOKEN")
90
  # will use api to restart space on a unrecoverable error
91
  api = HfApi(token=HF_TOKEN)
92
 
93
- repo_id = "coqui/voice-chat-with-zephyr"
94
 
95
 
96
  default_system_message = f"""
@@ -208,41 +208,13 @@ def format_prompt_zephyr(message, history, system_message=system_message):
208
  print(prompt)
209
  return prompt
210
 
211
- def generate(
212
- prompt, history, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
213
- ):
214
- temperature = float(temperature)
215
- if temperature < 1e-2:
216
- temperature = 1e-2
217
- top_p = float(top_p)
218
-
219
- generate_kwargs = dict(
220
- temperature=temperature,
221
- max_tokens=max_new_tokens,
222
- max_new_tokens=max_new_tokens,
223
- top_p=top_p,
224
- stop=LLM_STOP_WORDS
225
- )
226
- formatted_prompt = format_prompt(prompt, history)
227
-
228
- del generate_kwargs["max_tokens"]
229
- del generate_kwargs["stop"]
230
-
231
- stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
232
- output = ""
233
-
234
- for response in stream:
235
- output += response.token.text
236
- yield output
237
- return output
238
-
239
  def generate_local(
240
  prompt,
241
  history,
242
  llm_model="zephyr",
243
  system_message=None,
244
- temperature=0.8,
245
- max_tokens=256,
246
  top_p=0.95,
247
  stop = LLM_STOP_WORDS
248
  ):
@@ -296,7 +268,7 @@ def generate_local(
296
  return
297
 
298
 
299
- output += response["choices"][0]["text"].replace("<|assistant|>","").replace("<|user|>","")
300
  yield output
301
 
302
  except Exception as e:
 
90
  # will use api to restart space on a unrecoverable error
91
  api = HfApi(token=HF_TOKEN)
92
 
93
+ repo_id = "coqui/voice-chat-with-mistral"
94
 
95
 
96
  default_system_message = f"""
 
208
  print(prompt)
209
  return prompt
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  def generate_local(
212
  prompt,
213
  history,
214
  llm_model="zephyr",
215
  system_message=None,
216
+ temperature=0.85,
217
+ max_tokens=128,
218
  top_p=0.95,
219
  stop = LLM_STOP_WORDS
220
  ):
 
268
  return
269
 
270
 
271
+ output += character.replace("<|assistant|>","").replace("<|user|>","")
272
  yield output
273
 
274
  except Exception as e: