Update app.py
Browse files
app.py
CHANGED
|
@@ -4,10 +4,10 @@ import torch
|
|
| 4 |
import gradio as gr
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
from langchain_groq import ChatGroq
|
| 7 |
-
from
|
| 8 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 9 |
from langchain_core.runnables import RunnablePassthrough
|
| 10 |
-
from
|
| 11 |
from langchain import hub
|
| 12 |
|
| 13 |
# Set API key (Replace with your actual key)
|
|
@@ -19,7 +19,7 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
| 19 |
# Initialize LLM and Embeddings with GPU if available
|
| 20 |
llm = ChatGroq(model="llama3-8b-8192")
|
| 21 |
model_name = "BAAI/bge-small-en"
|
| 22 |
-
hf_embeddings =
|
| 23 |
model_name=model_name,
|
| 24 |
model_kwargs={'device': device},
|
| 25 |
encode_kwargs={'normalize_embeddings': True}
|
|
@@ -91,5 +91,5 @@ with gr.Blocks() as demo:
|
|
| 91 |
process_button.click(process_pdf, inputs=pdf_input, outputs=output_message)
|
| 92 |
submit_button.click(ask_question, inputs=query_input, outputs=response_output)
|
| 93 |
|
| 94 |
-
#
|
| 95 |
-
demo.launch(share=True,
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
from langchain_groq import ChatGroq
|
| 7 |
+
from langchain_huggingface import HuggingFaceEmbeddings # Updated import
|
| 8 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 9 |
from langchain_core.runnables import RunnablePassthrough
|
| 10 |
+
from langchain_community.document_loaders import PyPDFLoader # Updated import
|
| 11 |
from langchain import hub
|
| 12 |
|
| 13 |
# Set API key (Replace with your actual key)
|
|
|
|
| 19 |
# Initialize LLM and Embeddings with GPU if available
|
| 20 |
llm = ChatGroq(model="llama3-8b-8192")
|
| 21 |
model_name = "BAAI/bge-small-en"
|
| 22 |
+
hf_embeddings = HuggingFaceEmbeddings( # Updated class
|
| 23 |
model_name=model_name,
|
| 24 |
model_kwargs={'device': device},
|
| 25 |
encode_kwargs={'normalize_embeddings': True}
|
|
|
|
| 91 |
process_button.click(process_pdf, inputs=pdf_input, outputs=output_message)
|
| 92 |
submit_button.click(ask_question, inputs=query_input, outputs=response_output)
|
| 93 |
|
| 94 |
+
# 🚀 Fixed launch (removed invalid 'theme' argument)
|
| 95 |
+
demo.launch(share=True, show_api=False, timeout=60)
|