Daemontatox commited on
Commit
65735a4
·
verified ·
1 Parent(s): b66349f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -191,7 +191,6 @@ def chat_response(
191
  temperature=temperature,
192
  chat_history=chat_history,
193
  prompt_truncation='AUTO',
194
- connectors=[{"id": "web-search"}],
195
  preamble=system_prompt
196
  )
197
 
@@ -200,13 +199,19 @@ def chat_response(
200
  history = history + [[message, ""]]
201
 
202
  # Process stream
203
- for event in stream:
204
- if event.event_type == "text-generation":
205
- buffer += event.text
206
- formatted_buffer = format_text(buffer)
207
- history[-1][1] = formatted_buffer
208
- chat_display = format_chat_history(history)
209
- yield history, chat_display
 
 
 
 
 
 
210
 
211
  def process_example(example: str) -> tuple:
212
  """Process example query and return empty history and updated display"""
 
191
  temperature=temperature,
192
  chat_history=chat_history,
193
  prompt_truncation='AUTO',
 
194
  preamble=system_prompt
195
  )
196
 
 
199
  history = history + [[message, ""]]
200
 
201
  # Process stream
202
+ try:
203
+ for event in stream:
204
+ if event.event_type == "text-generation":
205
+ buffer += event.text
206
+ formatted_buffer = format_text(buffer)
207
+ history[-1][1] = formatted_buffer
208
+ chat_display = format_chat_history(history)
209
+ yield history, chat_display
210
+ except cohere.errors.CohereError as e:
211
+ error_message = f"Error: {str(e)}"
212
+ history[-1][1] = error_message
213
+ chat_display = format_chat_history(history)
214
+ yield history, chat_display
215
 
216
  def process_example(example: str) -> tuple:
217
  """Process example query and return empty history and updated display"""