Spaces:
Sleeping
Sleeping
moved envars to config
Browse files
config.py
CHANGED
@@ -5,6 +5,8 @@ from rag_app.database.db_handler import DataBaseHandler
|
|
5 |
load_dotenv()
|
6 |
|
7 |
SQLITE_FILE_NAME = os.getenv('SOURCES_CACHE')
|
|
|
|
|
8 |
|
9 |
|
10 |
db = DataBaseHandler()
|
|
|
5 |
load_dotenv()
|
6 |
|
7 |
SQLITE_FILE_NAME = os.getenv('SOURCES_CACHE')
|
8 |
+
PERSIST_DIRECTORY = os.getenv('VECTOR_DATABASE_LOCATION')
|
9 |
+
EMBEDDING_MODEL = os.getenv("EMBEDDING_MODEL")
|
10 |
|
11 |
|
12 |
db = DataBaseHandler()
|
rag_app/structured_tools/structured_tools.py
CHANGED
@@ -9,27 +9,23 @@ from rag_app.utils.utils import (
|
|
9 |
)
|
10 |
import chromadb
|
11 |
import os
|
12 |
-
from config import db
|
13 |
|
14 |
|
15 |
-
|
16 |
-
persist_directory = os.getenv('VECTOR_DATABASE_LOCATION')
|
17 |
-
embedding_model = os.getenv("EMBEDDING_MODEL")
|
18 |
-
|
19 |
@tool
|
20 |
def memory_search(query:str) -> str:
|
21 |
"""Search the memory vector store for existing knowledge and relevent pervious researches. \
|
22 |
This is your primary source to start your search with checking what you already have learned from the past, before going online."""
|
23 |
# Since we have more than one collections we should change the name of this tool
|
24 |
client = chromadb.PersistentClient(
|
25 |
-
path=
|
26 |
)
|
27 |
|
28 |
collection_name = os.getenv('CONVERSATION_COLLECTION_NAME')
|
29 |
#store using envar
|
30 |
|
31 |
embedding_function = SentenceTransformerEmbeddings(
|
32 |
-
model_name=
|
33 |
)
|
34 |
|
35 |
vector_db = Chroma(
|
@@ -44,6 +40,7 @@ def memory_search(query:str) -> str:
|
|
44 |
|
45 |
return docs.__str__()
|
46 |
|
|
|
47 |
@tool
|
48 |
def knowledgeBase_search(query:str) -> str:
|
49 |
"""Suche die interne Datenbank nach passenden Versicherungsprodukten und Informationen zu den Versicherungen"""
|
@@ -56,7 +53,7 @@ def knowledgeBase_search(query:str) -> str:
|
|
56 |
#store using envar
|
57 |
|
58 |
embedding_function = SentenceTransformerEmbeddings(
|
59 |
-
model_name=
|
60 |
)
|
61 |
|
62 |
# vector_db = Chroma(
|
@@ -64,7 +61,7 @@ def knowledgeBase_search(query:str) -> str:
|
|
64 |
# #collection_name=collection_name,
|
65 |
# embedding_function=embedding_function,
|
66 |
# )
|
67 |
-
vector_db = Chroma(persist_directory=
|
68 |
retriever = vector_db.as_retriever(search_type="mmr", search_kwargs={'k':5, 'fetch_k':10})
|
69 |
# This is deprecated, changed to invoke
|
70 |
# LangChainDeprecationWarning: The method `BaseRetriever.get_relevant_documents` was deprecated in langchain-core 0.1.46 and will be removed in 0.3.0. Use invoke instead.
|
@@ -74,6 +71,7 @@ def knowledgeBase_search(query:str) -> str:
|
|
74 |
|
75 |
return docs.__str__()
|
76 |
|
|
|
77 |
@tool
|
78 |
def google_search(query: str) -> str:
|
79 |
"""Verbessere die Ergebnisse durch eine Suche über die Webseite der Versicherung. Erstelle eine neue Suchanfrage, um die Erfolgschancen zu verbesseren."""
|
|
|
9 |
)
|
10 |
import chromadb
|
11 |
import os
|
12 |
+
from config import db, PERSIST_DIRECTORY, EMBEDDING_MODEL
|
13 |
|
14 |
|
|
|
|
|
|
|
|
|
15 |
@tool
|
16 |
def memory_search(query:str) -> str:
|
17 |
"""Search the memory vector store for existing knowledge and relevent pervious researches. \
|
18 |
This is your primary source to start your search with checking what you already have learned from the past, before going online."""
|
19 |
# Since we have more than one collections we should change the name of this tool
|
20 |
client = chromadb.PersistentClient(
|
21 |
+
path=PERSIST_DIRECTORY,
|
22 |
)
|
23 |
|
24 |
collection_name = os.getenv('CONVERSATION_COLLECTION_NAME')
|
25 |
#store using envar
|
26 |
|
27 |
embedding_function = SentenceTransformerEmbeddings(
|
28 |
+
model_name=EMBEDDING_MODEL,
|
29 |
)
|
30 |
|
31 |
vector_db = Chroma(
|
|
|
40 |
|
41 |
return docs.__str__()
|
42 |
|
43 |
+
|
44 |
@tool
|
45 |
def knowledgeBase_search(query:str) -> str:
|
46 |
"""Suche die interne Datenbank nach passenden Versicherungsprodukten und Informationen zu den Versicherungen"""
|
|
|
53 |
#store using envar
|
54 |
|
55 |
embedding_function = SentenceTransformerEmbeddings(
|
56 |
+
model_name=EMBEDDING_MODEL
|
57 |
)
|
58 |
|
59 |
# vector_db = Chroma(
|
|
|
61 |
# #collection_name=collection_name,
|
62 |
# embedding_function=embedding_function,
|
63 |
# )
|
64 |
+
vector_db = Chroma(persist_directory=PERSIST_DIRECTORY, embedding_function=embedding_function)
|
65 |
retriever = vector_db.as_retriever(search_type="mmr", search_kwargs={'k':5, 'fetch_k':10})
|
66 |
# This is deprecated, changed to invoke
|
67 |
# LangChainDeprecationWarning: The method `BaseRetriever.get_relevant_documents` was deprecated in langchain-core 0.1.46 and will be removed in 0.3.0. Use invoke instead.
|
|
|
71 |
|
72 |
return docs.__str__()
|
73 |
|
74 |
+
|
75 |
@tool
|
76 |
def google_search(query: str) -> str:
|
77 |
"""Verbessere die Ergebnisse durch eine Suche über die Webseite der Versicherung. Erstelle eine neue Suchanfrage, um die Erfolgschancen zu verbesseren."""
|