File size: 764 Bytes
6f77181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47fdf11
38768ad
 
6f77181
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
import chainlit as cl
from chainlit.input_widget import TextInput
from rag import RAGModel
import os
import nest_asyncio
nest_asyncio.apply()


# Initialize RAG model
rag_model = RAGModel(openai_api_key=os.getenv("OPENAI_API_KEY"))

@cl.on_message
async def main(message):
    result = rag_model.query(message.content)
    print(result)
    await cl.Message(result).send()

# @cl.application
# def app():
#     cl.TextInput(label="Enter your query", on_submit=handle_message)

@cl.on_chat_start
async def start():
#def on_chat_start():
    msg=cl.Message(content="Firing up the research info bot...")
    await msg.send()
    msg.content= "Hi, welcome to research info bot. What is your query?"
    await msg.update()

# if __name__ == "__main__":
#     cl.run()