chelleboyer commited on
Commit
0ea56cb
·
1 Parent(s): 57bf226

fix arguement error

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -213,28 +213,27 @@ async def main(message: cl.Message):
213
  try:
214
  lcel_rag_chain = cl.user_session.get("lcel_rag_chain")
215
 
216
- # Create a message to stream to
217
- msg = cl.Message(content="")
218
- await msg.send()
219
-
220
  # Get the response as a single string
221
  response = await cl.make_async(lcel_rag_chain.invoke)(
222
  {"query": message.content},
223
  config=RunnableConfig(callbacks=[cl.LangchainCallbackHandler()]),
224
  )
225
 
226
- # Update the message with the complete response
227
- await msg.update(response)
 
 
 
228
 
229
  except Exception as e:
230
  error_message = str(e)
231
  if "Connection reset by peer" in error_message or "Connection aborted" in error_message:
232
  await cl.Message(
233
  content="I apologize, but I'm having trouble connecting to the language model right now. Please try again in a few moments. If the problem persists, the service might be temporarily unavailable.",
234
- author="System"
235
  ).send()
236
  else:
237
  await cl.Message(
238
  content=f"An error occurred: {error_message}. Please try again.",
239
- author="System"
240
  ).send()
 
213
  try:
214
  lcel_rag_chain = cl.user_session.get("lcel_rag_chain")
215
 
 
 
 
 
216
  # Get the response as a single string
217
  response = await cl.make_async(lcel_rag_chain.invoke)(
218
  {"query": message.content},
219
  config=RunnableConfig(callbacks=[cl.LangchainCallbackHandler()]),
220
  )
221
 
222
+ # Send the response message
223
+ await cl.Message(
224
+ content=response,
225
+ author="Paul Graham Essay Bot"
226
+ ).send()
227
 
228
  except Exception as e:
229
  error_message = str(e)
230
  if "Connection reset by peer" in error_message or "Connection aborted" in error_message:
231
  await cl.Message(
232
  content="I apologize, but I'm having trouble connecting to the language model right now. Please try again in a few moments. If the problem persists, the service might be temporarily unavailable.",
233
+ author="Paul Graham Essay Bot"
234
  ).send()
235
  else:
236
  await cl.Message(
237
  content=f"An error occurred: {error_message}. Please try again.",
238
+ author="Paul Graham Essay Bot"
239
  ).send()