Spaces:
Sleeping
Sleeping
Fix OpenAI embeddings initialization and update package versions
Browse files- preprocess/embed_documents.py +5 -1
- requirements.txt +1 -1
preprocess/embed_documents.py
CHANGED
|
@@ -5,11 +5,15 @@ from langchain_openai import OpenAIEmbeddings
|
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
import json
|
| 7 |
import numpy as np
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def create_or_load_vectorstore(docs: list[Document], path: str = "generated/vectorstore") -> FAISS:
|
| 11 |
path = Path(path)
|
| 12 |
-
embeddings = OpenAIEmbeddings(
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
if path.exists():
|
| 15 |
print("✅ Loading FAISS VectorStore from disk...")
|
|
|
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
import json
|
| 7 |
import numpy as np
|
| 8 |
+
import os
|
| 9 |
|
| 10 |
|
| 11 |
def create_or_load_vectorstore(docs: list[Document], path: str = "generated/vectorstore") -> FAISS:
|
| 12 |
path = Path(path)
|
| 13 |
+
embeddings = OpenAIEmbeddings(
|
| 14 |
+
model="text-embedding-3-small",
|
| 15 |
+
openai_api_key=os.getenv("OPENAI_API_KEY")
|
| 16 |
+
)
|
| 17 |
|
| 18 |
if path.exists():
|
| 19 |
print("✅ Loading FAISS VectorStore from disk...")
|
requirements.txt
CHANGED
|
@@ -5,7 +5,7 @@ langchain-openai==0.0.8
|
|
| 5 |
langgraph==0.0.26
|
| 6 |
beautifulsoup4==4.12.3
|
| 7 |
pydantic>=2.5.3,<3.0.0
|
| 8 |
-
openai
|
| 9 |
tiktoken==0.6.0
|
| 10 |
faiss-cpu==1.10.0
|
| 11 |
langsmith>=0.1.0,<0.2.0
|
|
|
|
| 5 |
langgraph==0.0.26
|
| 6 |
beautifulsoup4==4.12.3
|
| 7 |
pydantic>=2.5.3,<3.0.0
|
| 8 |
+
openai>=1.12.0,<2.0.0
|
| 9 |
tiktoken==0.6.0
|
| 10 |
faiss-cpu==1.10.0
|
| 11 |
langsmith>=0.1.0,<0.2.0
|