Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,7 @@ import gradio as gr
|
|
| 3 |
from langchain.chains import RetrievalQA
|
| 4 |
from langchain_community.vectorstores import Chroma
|
| 5 |
from langchain_community.llms import OpenAI # β
Fixed Import
|
| 6 |
-
from langchain_huggingface import HuggingFaceEndpoint # β
Fixed Import
|
| 7 |
-
from langchain_community.embeddings import OpenAIEmbeddings, HuggingFaceEmbeddings # β
Fixed Import
|
| 8 |
from langchain_community.document_loaders import PyPDFLoader # β
Fixed Import
|
| 9 |
import time
|
| 10 |
|
|
@@ -30,7 +29,7 @@ def load_data():
|
|
| 30 |
loader = PyPDFLoader(pdf)
|
| 31 |
all_docs.extend(loader.load())
|
| 32 |
|
| 33 |
-
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2") # β
|
| 34 |
|
| 35 |
return Chroma.from_documents(all_docs, embeddings)
|
| 36 |
|
|
@@ -51,7 +50,7 @@ qa_chain = RetrievalQA.from_chain_type(llm=llm, retriever=vector_db.as_retriever
|
|
| 51 |
# Function to simulate futuristic typing effect
|
| 52 |
def chatbot_response(question):
|
| 53 |
"""Handles chatbot queries with a typing effect"""
|
| 54 |
-
response = qa_chain.invoke(question) # β
Use invoke instead of deprecated `run`
|
| 55 |
displayed_response = ""
|
| 56 |
for char in response:
|
| 57 |
displayed_response += char
|
|
|
|
| 3 |
from langchain.chains import RetrievalQA
|
| 4 |
from langchain_community.vectorstores import Chroma
|
| 5 |
from langchain_community.llms import OpenAI # β
Fixed Import
|
| 6 |
+
from langchain_huggingface import HuggingFaceEndpoint, HuggingFaceEmbeddings # β
Fixed Import
|
|
|
|
| 7 |
from langchain_community.document_loaders import PyPDFLoader # β
Fixed Import
|
| 8 |
import time
|
| 9 |
|
|
|
|
| 29 |
loader = PyPDFLoader(pdf)
|
| 30 |
all_docs.extend(loader.load())
|
| 31 |
|
| 32 |
+
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2") # β
Updated import
|
| 33 |
|
| 34 |
return Chroma.from_documents(all_docs, embeddings)
|
| 35 |
|
|
|
|
| 50 |
# Function to simulate futuristic typing effect
|
| 51 |
def chatbot_response(question):
|
| 52 |
"""Handles chatbot queries with a typing effect"""
|
| 53 |
+
response = qa_chain.invoke(question) # β
Use `invoke` instead of deprecated `run`
|
| 54 |
displayed_response = ""
|
| 55 |
for char in response:
|
| 56 |
displayed_response += char
|