Spaces:
Build error
Build error
Update rag.py
Browse files
rag.py
CHANGED
@@ -63,33 +63,33 @@ def document_splitting(config, docs):
|
|
63 |
|
64 |
def document_storage_chroma(chunks):
|
65 |
Chroma.from_documents(documents = chunks,
|
66 |
-
embedding = OpenAIEmbeddings(
|
67 |
persist_directory = CHROMA_DIR)
|
68 |
|
69 |
def document_storage_mongodb(chunks):
|
70 |
MongoDBAtlasVectorSearch.from_documents(documents = chunks,
|
71 |
-
embedding = OpenAIEmbeddings(
|
72 |
collection = collection,
|
73 |
index_name = MONGODB_INDEX_NAME)
|
74 |
|
75 |
-
def rag_batch(config):
|
76 |
-
docs = document_loading()
|
77 |
-
|
78 |
-
chunks = document_splitting(config, docs)
|
79 |
-
|
80 |
-
document_storage_chroma(chunks)
|
81 |
-
document_storage_mongodb(chunks)
|
82 |
-
|
83 |
def document_retrieval_chroma():
|
84 |
-
return Chroma(embedding_function = OpenAIEmbeddings(
|
85 |
persist_directory = CHROMA_DIR)
|
86 |
|
87 |
def document_retrieval_mongodb():
|
88 |
return MongoDBAtlasVectorSearch.from_connection_string(MONGODB_ATLAS_CLUSTER_URI,
|
89 |
MONGODB_DB_NAME + "." + MONGODB_COLLECTION_NAME,
|
90 |
-
OpenAIEmbeddings(
|
91 |
index_name = MONGODB_INDEX_NAME)
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
def get_llm(config, openai_api_key):
|
94 |
return ChatOpenAI(model_name = config["model_name"],
|
95 |
openai_api_key = openai_api_key,
|
|
|
63 |
|
64 |
def document_storage_chroma(chunks):
|
65 |
Chroma.from_documents(documents = chunks,
|
66 |
+
embedding = OpenAIEmbeddings(),
|
67 |
persist_directory = CHROMA_DIR)
|
68 |
|
69 |
def document_storage_mongodb(chunks):
|
70 |
MongoDBAtlasVectorSearch.from_documents(documents = chunks,
|
71 |
+
embedding = OpenAIEmbeddings(),
|
72 |
collection = collection,
|
73 |
index_name = MONGODB_INDEX_NAME)
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
def document_retrieval_chroma():
|
76 |
+
return Chroma(embedding_function = OpenAIEmbeddings(),
|
77 |
persist_directory = CHROMA_DIR)
|
78 |
|
79 |
def document_retrieval_mongodb():
|
80 |
return MongoDBAtlasVectorSearch.from_connection_string(MONGODB_ATLAS_CLUSTER_URI,
|
81 |
MONGODB_DB_NAME + "." + MONGODB_COLLECTION_NAME,
|
82 |
+
OpenAIEmbeddings(),
|
83 |
index_name = MONGODB_INDEX_NAME)
|
84 |
|
85 |
+
def rag_batch(config):
|
86 |
+
docs = document_loading()
|
87 |
+
|
88 |
+
chunks = document_splitting(config, docs)
|
89 |
+
|
90 |
+
document_storage_chroma(chunks)
|
91 |
+
document_storage_mongodb(chunks)
|
92 |
+
|
93 |
def get_llm(config, openai_api_key):
|
94 |
return ChatOpenAI(model_name = config["model_name"],
|
95 |
openai_api_key = openai_api_key,
|