Spaces:
Sleeping
Sleeping
attempt to use rag_config
Browse files
rag_app/__init__.py
CHANGED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from pathlib import Path
|
3 |
+
|
4 |
+
# Add the project root to the Python path
|
5 |
+
project_root = str(Path(__file__).parent.parent)
|
6 |
+
if project_root not in sys.path:
|
7 |
+
sys.path.append(project_root)
|
rag_app/vector_store_handler/vectorstores.py
CHANGED
@@ -4,6 +4,14 @@ from langchain.embeddings import OpenAIEmbeddings
|
|
4 |
from langchain.text_splitter import CharacterTextSplitter
|
5 |
from langchain.document_loaders import TextLoader
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
class BaseVectorStore(ABC):
|
8 |
"""
|
9 |
Abstract base class for vector stores.
|
@@ -170,10 +178,13 @@ def main():
|
|
170 |
"""
|
171 |
# Create an embedding model
|
172 |
embedding_model = OpenAIEmbeddings()
|
|
|
|
|
|
|
173 |
|
174 |
# Using Chroma
|
175 |
chroma_store = ChromaVectorStore(embedding_model, persist_directory="./chroma_store")
|
176 |
-
texts = chroma_store.load_and_process_documents("
|
177 |
chroma_store.create_vectorstore(texts)
|
178 |
results = chroma_store.similarity_search("Your query here")
|
179 |
print("Chroma results:", results[0].page_content)
|
|
|
4 |
from langchain.text_splitter import CharacterTextSplitter
|
5 |
from langchain.document_loaders import TextLoader
|
6 |
|
7 |
+
|
8 |
+
from langchain_community.embeddings.sentence_transformer import (
|
9 |
+
SentenceTransformerEmbeddings,
|
10 |
+
)
|
11 |
+
import time
|
12 |
+
from langchain_core.documents import Document
|
13 |
+
from config import EMBEDDING_MODEL
|
14 |
+
|
15 |
class BaseVectorStore(ABC):
|
16 |
"""
|
17 |
Abstract base class for vector stores.
|
|
|
178 |
"""
|
179 |
# Create an embedding model
|
180 |
embedding_model = OpenAIEmbeddings()
|
181 |
+
|
182 |
+
embeddings = SentenceTransformerEmbeddings(model_name=EMBEDDING_MODEL)
|
183 |
+
|
184 |
|
185 |
# Using Chroma
|
186 |
chroma_store = ChromaVectorStore(embedding_model, persist_directory="./chroma_store")
|
187 |
+
texts = chroma_store.load_and_process_documents("docs/placeholder.txt")
|
188 |
chroma_store.create_vectorstore(texts)
|
189 |
results = chroma_store.similarity_search("Your query here")
|
190 |
print("Chroma results:", results[0].page_content)
|