Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,11 @@ from langchain_openai import OpenAIEmbeddings
|
|
16 |
from langchain_openai import ChatOpenAI
|
17 |
|
18 |
# Load the FAISS index from the .pkl file
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
db = FAISS.load_local("faiss_index", embeddings,allow_dangerous_deserialization=True)
|
21 |
|
22 |
def get_response_from_query(db, query, k=3):
|
|
|
16 |
from langchain_openai import ChatOpenAI
|
17 |
|
18 |
# Load the FAISS index from the .pkl file
|
19 |
+
openai_api_key = os.getenv("OPENAI_API_KEY")
|
20 |
+
if not openai_api_key:
|
21 |
+
raise ValueError("OPENAI_API_KEY environment variable is not set.")
|
22 |
+
|
23 |
+
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
|
24 |
db = FAISS.load_local("faiss_index", embeddings,allow_dangerous_deserialization=True)
|
25 |
|
26 |
def get_response_from_query(db, query, k=3):
|