cotxetj commited on
Commit
eccdcbf
1 Parent(s): e806549

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -117,6 +117,7 @@ def gpt_predict(inputs, request:gr.Request=gr.State([]), top_p = 1, temperature
117
 
118
  try:
119
  # make a POST request to the API endpoint using the requests.post method, passing in stream=True
 
120
  response = requests.post(API_URL, headers=headers, json=payload, stream=True)
121
  response_code = f"{response}"
122
  print(response_code)
@@ -144,9 +145,9 @@ def gpt_predict(inputs, request:gr.Request=gr.State([]), top_p = 1, temperature
144
  return [(parse_codeblock(history[i]), parse_codeblock(history[i + 1])) for i in range(0, len(history) - 1, 2) ], history, chat_counter, response, gr.update(interactive=False), gr.update(interactive=False) # resembles {chatbot: chat, state: history}
145
  except Exception as e:
146
  print (f'error found: {e}')
147
- yield [(parse_codeblock(history[i]), parse_codeblock(history[i + 1])) for i in range(0, len(history) - 1, 2) ], history, chat_counter, response, gr.update(interactive=True), gr.update(interactive=True)
148
  print(json.dumps({"chat_counter": chat_counter, "payload": payload, "partial_words": partial_words, "token_counter": token_counter, "counter": counter}))
149
-
 
150
 
151
  # Define the pipeline
152
  def speech_to_speech_translation(audio):
@@ -160,7 +161,7 @@ def predict(transType, language, audio, audio_mic = None):
160
  print("debug1:", audio,"debug2", audio_mic)
161
  if not audio and audio_mic:
162
  audio = audio_mic
163
-
164
  if transType == "Text":
165
  return translate(audio), None
166
  if transType == "GPT answer":
 
117
 
118
  try:
119
  # make a POST request to the API endpoint using the requests.post method, passing in stream=True
120
+ print('in the try')
121
  response = requests.post(API_URL, headers=headers, json=payload, stream=True)
122
  response_code = f"{response}"
123
  print(response_code)
 
145
  return [(parse_codeblock(history[i]), parse_codeblock(history[i + 1])) for i in range(0, len(history) - 1, 2) ], history, chat_counter, response, gr.update(interactive=False), gr.update(interactive=False) # resembles {chatbot: chat, state: history}
146
  except Exception as e:
147
  print (f'error found: {e}')
 
148
  print(json.dumps({"chat_counter": chat_counter, "payload": payload, "partial_words": partial_words, "token_counter": token_counter, "counter": counter}))
149
+ return [(parse_codeblock(history[i]), parse_codeblock(history[i + 1])) for i in range(0, len(history) - 1, 2) ], history, chat_counter, response, gr.update(interactive=True), gr.update(interactive=True)
150
+
151
 
152
  # Define the pipeline
153
  def speech_to_speech_translation(audio):
 
161
  print("debug1:", audio,"debug2", audio_mic)
162
  if not audio and audio_mic:
163
  audio = audio_mic
164
+ return gpt_predict("What time is it?")
165
  if transType == "Text":
166
  return translate(audio), None
167
  if transType == "GPT answer":