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 langchain_community.document_loaders import PyPDFLoader #
|
| 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}
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
from langchain_groq import ChatGroq
|
| 7 |
+
from langchain_community.embeddings import HuggingFaceBgeEmbeddings # Fixed import
|
| 8 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 9 |
from langchain_core.runnables import RunnablePassthrough
|
| 10 |
+
from langchain_community.document_loaders import PyPDFLoader # Fixed 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 = HuggingFaceBgeEmbeddings( # Fixed import
|
| 23 |
model_name=model_name,
|
| 24 |
model_kwargs={'device': device},
|
| 25 |
encode_kwargs={'normalize_embeddings': True}
|