Spaces:
Sleeping
Sleeping
third commit
Browse files- Dockerfile +1 -1
- app.py +12 -5
- earnings_app.py +9 -9
Dockerfile
CHANGED
|
@@ -8,4 +8,4 @@ COPY --chown=user . $HOME/app
|
|
| 8 |
COPY ./requirements.txt ~/app/requirements.txt
|
| 9 |
RUN pip install -r requirements.txt
|
| 10 |
COPY . .
|
| 11 |
-
CMD ["chainlit", "run", "
|
|
|
|
| 8 |
COPY ./requirements.txt ~/app/requirements.txt
|
| 9 |
RUN pip install -r requirements.txt
|
| 10 |
COPY . .
|
| 11 |
+
CMD ["chainlit", "run", "app.py", "--port", "7860"]
|
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
-
import chainlit as cl
|
| 2 |
import sys
|
| 3 |
|
| 4 |
sys.path.append(".")
|
| 5 |
|
|
|
|
|
|
|
| 6 |
from earnings_app import extract_information
|
| 7 |
|
| 8 |
@cl.author_rename
|
|
@@ -13,15 +14,21 @@ def rename(orig_author: str):
|
|
| 13 |
return rename_dict.get(orig_author, orig_author)
|
| 14 |
|
| 15 |
@cl.on_chat_start
|
| 16 |
-
async def
|
|
|
|
|
|
|
|
|
|
| 17 |
cl.user_session.set("chain", extract_information())
|
| 18 |
-
await cl.Message(
|
| 19 |
|
| 20 |
@cl.on_message
|
| 21 |
async def main(message: cl.Message):
|
|
|
|
|
|
|
|
|
|
| 22 |
chain = cl.user_session.get("chain")
|
| 23 |
-
res = chain.
|
| 24 |
# res = await chain.aiinvoke({"input": message})
|
| 25 |
# res = res["text"]
|
| 26 |
-
out =
|
| 27 |
await cl.Message(content=out).send()
|
|
|
|
|
|
|
| 1 |
import sys
|
| 2 |
|
| 3 |
sys.path.append(".")
|
| 4 |
|
| 5 |
+
import chainlit as cl
|
| 6 |
+
|
| 7 |
from earnings_app import extract_information
|
| 8 |
|
| 9 |
@cl.author_rename
|
|
|
|
| 14 |
return rename_dict.get(orig_author, orig_author)
|
| 15 |
|
| 16 |
@cl.on_chat_start
|
| 17 |
+
async def start():
|
| 18 |
+
"""
|
| 19 |
+
This is called when the Chainlit chat is started!
|
| 20 |
+
"""
|
| 21 |
cl.user_session.set("chain", extract_information())
|
| 22 |
+
await cl.Message("Welcome to the information extraction chat!").send()
|
| 23 |
|
| 24 |
@cl.on_message
|
| 25 |
async def main(message: cl.Message):
|
| 26 |
+
"""
|
| 27 |
+
This is called when a message is received!
|
| 28 |
+
"""
|
| 29 |
chain = cl.user_session.get("chain")
|
| 30 |
+
res = await chain.achat(message)
|
| 31 |
# res = await chain.aiinvoke({"input": message})
|
| 32 |
# res = res["text"]
|
| 33 |
+
out = str(res)
|
| 34 |
await cl.Message(content=out).send()
|
earnings_app.py
CHANGED
|
@@ -171,16 +171,16 @@ def extract_information():
|
|
| 171 |
return agent
|
| 172 |
|
| 173 |
|
| 174 |
-
if __name__ == "__main__":
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
|
| 179 |
-
|
| 180 |
-
|
| 181 |
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
|
| 186 |
asyncio.run(main())
|
|
|
|
| 171 |
return agent
|
| 172 |
|
| 173 |
|
| 174 |
+
# if __name__ == "__main__":
|
| 175 |
+
# text = "Who is the CEO of MSFT."
|
| 176 |
+
# chain = extract_information()
|
| 177 |
+
# print(str(chain.chat(text)))
|
| 178 |
|
| 179 |
+
# async def extract_information_async(message: str):
|
| 180 |
+
# return str(chain.chat(text))
|
| 181 |
|
| 182 |
+
# async def main():
|
| 183 |
+
# res = await extract_information_async(text)
|
| 184 |
+
# print(res)
|
| 185 |
|
| 186 |
asyncio.run(main())
|