Spaces:
Runtime error
Runtime error
sanjeevl10
commited on
Commit
•
911e021
1
Parent(s):
2459c07
added openai call
Browse files- app.py +3 -3
- requirements.txt +1 -1
app.py
CHANGED
@@ -7,7 +7,7 @@ from langchain_text_splitters import RecursiveCharacterTextSplitter
|
|
7 |
from langchain.document_loaders import PyMuPDFLoader
|
8 |
from langchain_huggingface import HuggingFaceEndpointEmbeddings
|
9 |
from langchain_core.prompts import PromptTemplate
|
10 |
-
from
|
11 |
from langchain.schema.runnable.config import RunnableConfig
|
12 |
from langchain_community.vectorstores import Qdrant
|
13 |
|
@@ -27,7 +27,7 @@ We will load our environment variables here.
|
|
27 |
HF_LLM_ENDPOINT = os.environ["HF_LLM_ENDPOINT"]
|
28 |
HF_EMBED_ENDPOINT = os.environ["HF_EMBED_ENDPOINT"]
|
29 |
HF_TOKEN = os.environ["HF_TOKEN"]
|
30 |
-
|
31 |
|
32 |
# ---- GLOBAL DECLARATIONS ---- #
|
33 |
|
@@ -49,7 +49,7 @@ text_splitter = RecursiveCharacterTextSplitter(
|
|
49 |
split_documents = text_splitter.split_documents(documents)
|
50 |
|
51 |
### 3. LOAD open ai EMBEDDINGS
|
52 |
-
embeddings = OpenAI(model="text-embedding-ada-002")
|
53 |
|
54 |
#Initialize the Vector Store
|
55 |
if os.path.exists("./vectorstore"):
|
|
|
7 |
from langchain.document_loaders import PyMuPDFLoader
|
8 |
from langchain_huggingface import HuggingFaceEndpointEmbeddings
|
9 |
from langchain_core.prompts import PromptTemplate
|
10 |
+
from langchain_openai.embeddings import OpenAI
|
11 |
from langchain.schema.runnable.config import RunnableConfig
|
12 |
from langchain_community.vectorstores import Qdrant
|
13 |
|
|
|
27 |
HF_LLM_ENDPOINT = os.environ["HF_LLM_ENDPOINT"]
|
28 |
HF_EMBED_ENDPOINT = os.environ["HF_EMBED_ENDPOINT"]
|
29 |
HF_TOKEN = os.environ["HF_TOKEN"]
|
30 |
+
OPENAPI_KEY = os.environ["OPENAI_API_KEY"]
|
31 |
|
32 |
# ---- GLOBAL DECLARATIONS ---- #
|
33 |
|
|
|
49 |
split_documents = text_splitter.split_documents(documents)
|
50 |
|
51 |
### 3. LOAD open ai EMBEDDINGS
|
52 |
+
embeddings = OpenAI(OPENAPI_API_KEY=OPENAPI_KEY,model="text-embedding-ada-002")
|
53 |
|
54 |
#Initialize the Vector Store
|
55 |
if os.path.exists("./vectorstore"):
|
requirements.txt
CHANGED
@@ -4,8 +4,8 @@ langchain_community==0.2.5
|
|
4 |
langchain_core==0.2.9
|
5 |
langchain_huggingface==0.0.3
|
6 |
langchain_text_splitters==0.2.1
|
|
|
7 |
python-dotenv==1.0.1
|
8 |
-
openai==0.25.0
|
9 |
pymupdf==1.24.5
|
10 |
faiss-cpu
|
11 |
qdrant-client==1.9.2
|
|
|
4 |
langchain_core==0.2.9
|
5 |
langchain_huggingface==0.0.3
|
6 |
langchain_text_splitters==0.2.1
|
7 |
+
langchain_openai==0.1.9
|
8 |
python-dotenv==1.0.1
|
|
|
9 |
pymupdf==1.24.5
|
10 |
faiss-cpu
|
11 |
qdrant-client==1.9.2
|