Download app.py from RajMoon/codepath: direct link, hf CLI and curl.
- Browser
- Download file 719 Bytes
-
https://huggingface.co/spaces/RajMoon/codepath/resolve/main/app.py
- Command line
-
hf download hf://spaces/RajMoon/codepath/app.py
-
curl -L -o app.py https://huggingface.co/spaces/RajMoon/codepath/resolve/main/app.py
719 Bytes
| 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")) | |
| 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() | |
| async def on_message(message: cl.Message): | |
| answer = rag.query(question=message.content) | |
| await cl.Message(content=answer).send() | |