Spaces:
Sleeping
Sleeping
Download chat_handler.py from chburhan64/PDF_Agent: direct link, hf CLI and curl.
- Browser
- Download file 465 Bytes
-
https://huggingface.co/spaces/chburhan64/PDF_Agent/resolve/main/chat_handler.py
- Command line
-
hf download hf://spaces/chburhan64/PDF_Agent/chat_handler.py
-
curl -L -o chat_handler.py https://huggingface.co/spaces/chburhan64/PDF_Agent/resolve/main/chat_handler.py
465 Bytes
| from langchain.chains import RetrievalQA | |
| def chat_with_paper(llm, vectorstore, query): | |
| """ | |
| Chat with the paper using Q&A | |
| Args: | |
| llm: Language model instance | |
| vectorstore: FAISS vector store | |
| query: User's question | |
| Returns: | |
| str: Answer to the question | |
| """ | |
| retriever = vectorstore.as_retriever() | |
| qa_chain = RetrievalQA.from_chain_type(llm=llm, retriever=retriever) | |
| return qa_chain.run(query) |