Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,22 +3,22 @@ from extract_app import extract_information
|
|
| 3 |
|
| 4 |
|
| 5 |
@cl.on_chat_start
|
| 6 |
-
def start():
|
| 7 |
"""
|
| 8 |
This is called when the Chainlit chat is started!
|
| 9 |
"""
|
| 10 |
-
cl.
|
|
|
|
| 11 |
|
| 12 |
@cl.on_message
|
| 13 |
async def main(message: cl.Message):
|
| 14 |
"""
|
| 15 |
This is called when a message is received!
|
| 16 |
"""
|
| 17 |
-
|
| 18 |
-
res = await
|
| 19 |
res = res["text"]
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
await cl.Message(content=res).send()
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
@cl.on_chat_start
|
| 6 |
+
async def start():
|
| 7 |
"""
|
| 8 |
This is called when the Chainlit chat is started!
|
| 9 |
"""
|
| 10 |
+
cl.user_session.set("chain", extract_information())
|
| 11 |
+
await cl.Message("Welcome to the information extraction chat!").send()
|
| 12 |
|
| 13 |
@cl.on_message
|
| 14 |
async def main(message: cl.Message):
|
| 15 |
"""
|
| 16 |
This is called when a message is received!
|
| 17 |
"""
|
| 18 |
+
chain = cl.user_session.get("chain")
|
| 19 |
+
res = await chain.ainvoke({"input": message})
|
| 20 |
res = res["text"]
|
| 21 |
+
out = "Name \tAge\n" + ''.join(
|
| 22 |
+
[f"{person.name}\t{person.age}\n" for person in res]
|
| 23 |
+
)
|
| 24 |
+
await cl.Message(content=out).send()
|
|
|