Spaces:
Sleeping
Sleeping
Download app.py from cmagganas/ExtractApp: direct link, hf CLI and curl.
- Browser
- Download file 687 Bytes
-
https://huggingface.co/spaces/cmagganas/ExtractApp/resolve/main/app.py
- Command line
-
hf download hf://spaces/cmagganas/ExtractApp/app.py
-
curl -L -o app.py https://huggingface.co/spaces/cmagganas/ExtractApp/resolve/main/app.py
687 Bytes
| import chainlit as cl | |
| from extract_app import extract_information | |
| async def start(): | |
| """ | |
| This is called when the Chainlit chat is started! | |
| """ | |
| cl.user_session.set("chain", extract_information()) | |
| await cl.Message("Welcome to the information extraction chat!").send() | |
| async def main(message: cl.Message): | |
| """ | |
| This is called when a message is received! | |
| """ | |
| chain = cl.user_session.get("chain") | |
| res = await chain.ainvoke({"input": message}) | |
| res = res["text"] | |
| out = "Name \tAge\n" | |
| out += ''.join( | |
| [f"{person.name}\t{person.age}\n" for person in res] | |
| ) | |
| await cl.Message(content=out).send() |