versae commited on
Commit
886c117
1 Parent(s): 8250089

Fixes chat for Spanish

Browse files
Files changed (1) hide show
  1. duplex.py +4 -3
duplex.py CHANGED
@@ -164,9 +164,10 @@ def chat_with_gpt(lang, agent, user, context, audio_in, history):
164
  break
165
  context += history_context
166
  for _ in range(5):
167
- response = generate(f"{context}\n\n{user}: {message}.\n", context_length=context_length, **generation_kwargs)
 
168
  if DEBUG:
169
- print("\n-----" + response + "-----\n")
170
  # response = response.split("\n")[-1]
171
  # if agent in response and response.split(agent)[-1]:
172
  # response = response.split(agent)[-1]
@@ -174,7 +175,7 @@ def chat_with_gpt(lang, agent, user, context, audio_in, history):
174
  # response = response.split(user)[-1]
175
  # Take the first response
176
  response = [
177
- r for r in response.split(f"{AGENT}:") if r.strip()
178
  ][0].split(USER)[0].replace(f"{AGENT}:", "\n").strip()
179
  if response and response[0] in string.punctuation:
180
  response = response[1:].strip()
 
164
  break
165
  context += history_context
166
  for _ in range(5):
167
+ prompt = f"{context}\n\n{user}: {message}.\n"
168
+ response = generate(prompt, context_length=context_length, **generation_kwargs)
169
  if DEBUG:
170
+ print("\n-----\n" + response + "\n-----\n")
171
  # response = response.split("\n")[-1]
172
  # if agent in response and response.split(agent)[-1]:
173
  # response = response.split(agent)[-1]
 
175
  # response = response.split(user)[-1]
176
  # Take the first response
177
  response = [
178
+ r for r in response.replace(prompt, "").split(f"{AGENT}:") if r.strip()
179
  ][0].split(USER)[0].replace(f"{AGENT}:", "\n").strip()
180
  if response and response[0] in string.punctuation:
181
  response = response[1:].strip()