Spaces:
Sleeping
Sleeping
Update rag_processor.py
Browse files- rag_processor.py +3 -2
rag_processor.py
CHANGED
|
@@ -5,6 +5,7 @@ from sentence_transformers import SentenceTransformer
|
|
| 5 |
import faiss
|
| 6 |
import numpy as np
|
| 7 |
from dotenv import load_dotenv
|
|
|
|
| 8 |
|
| 9 |
load_dotenv()
|
| 10 |
|
|
@@ -15,9 +16,9 @@ class RAGProcessor:
|
|
| 15 |
self.documents = []
|
| 16 |
self.openai_client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 17 |
|
| 18 |
-
def add_documents(self, documents: List[
|
| 19 |
"""Add documents to the RAG system."""
|
| 20 |
-
self.documents = documents
|
| 21 |
embeddings = self.model.encode(documents)
|
| 22 |
|
| 23 |
# Create FAISS index
|
|
|
|
| 5 |
import faiss
|
| 6 |
import numpy as np
|
| 7 |
from dotenv import load_dotenv
|
| 8 |
+
from langchain_core.documents import Document
|
| 9 |
|
| 10 |
load_dotenv()
|
| 11 |
|
|
|
|
| 16 |
self.documents = []
|
| 17 |
self.openai_client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 18 |
|
| 19 |
+
def add_documents(self, documents: List[Document]):
|
| 20 |
"""Add documents to the RAG system."""
|
| 21 |
+
self.documents = [doc.page_content for doc in documents]
|
| 22 |
embeddings = self.model.encode(documents)
|
| 23 |
|
| 24 |
# Create FAISS index
|