Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import pdfplumber
|
|
6 |
from langchain_community.vectorstores import FAISS
|
7 |
from langchain_openai import OpenAIEmbeddings
|
8 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
9 |
-
|
10 |
# Initialize system
|
11 |
@st.cache_resource
|
12 |
def init_system():
|
@@ -14,7 +14,13 @@ def init_system():
|
|
14 |
process_pdf("Q1FY24.pdf")
|
15 |
|
16 |
# 2. Load embeddings with secure API key
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# 3. Load vector store
|
20 |
vector_store = FAISS.load_local("faiss_index", embeddings)
|
|
|
6 |
from langchain_community.vectorstores import FAISS
|
7 |
from langchain_openai import OpenAIEmbeddings
|
8 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
9 |
+
from langchain_openai import OpenAIEmbeddings
|
10 |
# Initialize system
|
11 |
@st.cache_resource
|
12 |
def init_system():
|
|
|
14 |
process_pdf("Q1FY24.pdf")
|
15 |
|
16 |
# 2. Load embeddings with secure API key
|
17 |
+
|
18 |
+
|
19 |
+
# In both places where embeddings are initialized:
|
20 |
+
embeddings = OpenAIEmbeddings(
|
21 |
+
openai_api_key=os.getenv("OPENAI_API_KEY"),
|
22 |
+
model="text-embedding-ada-002" # Explicit model name
|
23 |
+
)
|
24 |
|
25 |
# 3. Load vector store
|
26 |
vector_store = FAISS.load_local("faiss_index", embeddings)
|