Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -90,17 +90,24 @@ async def on_chat_start():
|
|
90 |
|
91 |
@cl.on_message
|
92 |
async def on_message(message: cl.Message):
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
# @cl.on_message
|
106 |
# async def main(question):
|
|
|
90 |
|
91 |
@cl.on_message
|
92 |
async def on_message(message: cl.Message):
|
93 |
+
try:
|
94 |
+
logger.info('Starting application')
|
95 |
+
# Your main application logic here
|
96 |
+
runnable = cl.user_session.get("runnable") # type: Runnable
|
97 |
+
|
98 |
+
msg = cl.Message(content="")
|
99 |
+
|
100 |
+
async for chunk in runnable.astream(
|
101 |
+
{"question": message.content},
|
102 |
+
config=RunnableConfig(callbacks=[cl.LangchainCallbackHandler()]),
|
103 |
+
):
|
104 |
+
await msg.stream_token(chunk)
|
105 |
+
|
106 |
+
await cl.Message(content=response).send()
|
107 |
+
logger.info('Application finished successfully')
|
108 |
+
except Exception as e:
|
109 |
+
logger.exception("Unhandled exception: %s", e)
|
110 |
+
|
111 |
|
112 |
# @cl.on_message
|
113 |
# async def main(question):
|