File size: 719 Bytes
0539069 | 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 |
import os
from rag import RAGModel
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema import StrOutputParser
from langchain.chains import LLMChain
import chainlit as cl
# Get the value of OPEN_API_KEY from the environment
rag = RAGModel(os.getenv("OPENAI_API_KEY"))
@cl.on_chat_start
async 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()
@cl.on_message
async def on_message(message: cl.Message):
answer = rag.query(question=message.content)
await cl.Message(content=answer).send()
|