isayahc commited on
Commit
f790226
1 Parent(s): 1776f2f

added the retriever from conversation tool

Browse files
innovation_pathfinder_ai/structured_tools/structured_tools.py CHANGED
@@ -156,4 +156,29 @@ def embed_arvix_paper(paper_id:str) -> None:
156
  collection_name=collection_name,
157
  pdf_file_location=full_path,
158
  )
159
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  collection_name=collection_name,
157
  pdf_file_location=full_path,
158
  )
159
+
160
+ @tool
161
+ def conversational_search(query:str) -> str:
162
+ """Search from past conversations for docmunets and relevent chunks"""
163
+ # Since we have more than one collections we should change the name of this tool
164
+ client = chromadb.PersistentClient(
165
+ # path=persist_directory,
166
+ )
167
+
168
+ collection_name=os.getenv("CONVERSATION_COLLECTION_NAME")
169
+ #store using envar
170
+
171
+ embedding_function = SentenceTransformerEmbeddings(
172
+ model_name="all-MiniLM-L6-v2",
173
+ )
174
+
175
+ vector_db = Chroma(
176
+ client=client, # client for Chroma
177
+ collection_name=collection_name,
178
+ embedding_function=embedding_function,
179
+ )
180
+
181
+ retriever = vector_db.as_retriever()
182
+ docs = retriever.get_relevant_documents(query)
183
+
184
+ return docs.__str__()