eabybabu commited on
Commit
bbe760a
Β·
verified Β·
1 Parent(s): 301bbfc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
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") # βœ… Use updated embeddings
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