File size: 910 Bytes
78fb5d7
9253faf
78fb5d7
85824c0
b378e4d
 
78fb5d7
9253faf
6fd5283
 
 
 
 
 
 
9253faf
b378e4d
 
 
 
78fb5d7
b378e4d
9253faf
 
78fb5d7
b378e4d
 
 
9253faf
b378e4d
78fb5d7
 
b378e4d
78fb5d7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sys

sys.path.append(".")

import chainlit as cl

from earnings_app import extract_information

@cl.author_rename
def rename(orig_author: str):
    diamond_char = u'\U0001F537'
    phrase = diamond_char + " Diamond Hands " + diamond_char
    rename_dict = {"RetrievalQA": phrase}
    return rename_dict.get(orig_author, orig_author)

@cl.on_chat_start
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()

@cl.on_message
async def main(message: cl.Message):
    """
    This is called when a message is received!
    """
    chain = cl.user_session.get("chain")
    res = await chain.achat(message)
    # res = await chain.aiinvoke({"input": message})
    # res = res["text"]
    out = str(res)
    await cl.Message(content=out).send()