Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ from langchain_community.document_loaders import PyPDFLoader
|
|
| 4 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 7 |
-
from
|
| 8 |
from langchain.prompts import PromptTemplate
|
| 9 |
from langchain.chains import RetrievalQA
|
| 10 |
|
|
@@ -38,6 +38,7 @@ def process_file(file_path):
|
|
| 38 |
input_variables=["context", "question"]
|
| 39 |
)
|
| 40 |
|
|
|
|
| 41 |
llm = ChatGroq(
|
| 42 |
api_key=os.environ.get("GROQ_API_KEY"),
|
| 43 |
model_name="llama3-8b-8192"
|
|
@@ -72,7 +73,6 @@ async def handle_message(message: cl.Message):
|
|
| 72 |
file = files[0]
|
| 73 |
file_path = file.path
|
| 74 |
|
| 75 |
-
# Build RAG pipeline
|
| 76 |
qa_chain = await cl.make_async(process_file)(file_path)
|
| 77 |
cl.user_session.set("qa_chain", qa_chain)
|
| 78 |
cl.user_session.set("ready", True)
|
|
|
|
| 4 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 7 |
+
from langchain_groq import ChatGroq # ✅ Correct import
|
| 8 |
from langchain.prompts import PromptTemplate
|
| 9 |
from langchain.chains import RetrievalQA
|
| 10 |
|
|
|
|
| 38 |
input_variables=["context", "question"]
|
| 39 |
)
|
| 40 |
|
| 41 |
+
# ✅ Use Groq Chat Model
|
| 42 |
llm = ChatGroq(
|
| 43 |
api_key=os.environ.get("GROQ_API_KEY"),
|
| 44 |
model_name="llama3-8b-8192"
|
|
|
|
| 73 |
file = files[0]
|
| 74 |
file_path = file.path
|
| 75 |
|
|
|
|
| 76 |
qa_chain = await cl.make_async(process_file)(file_path)
|
| 77 |
cl.user_session.set("qa_chain", qa_chain)
|
| 78 |
cl.user_session.set("ready", True)
|