Spaces:
Runtime error
Runtime error
v0.8.4
Browse files- src/chromaIntf.py +8 -4
- src/main.py +3 -2
src/chromaIntf.py
CHANGED
@@ -70,11 +70,15 @@ class ChromaIntf():
|
|
70 |
)
|
71 |
|
72 |
|
73 |
-
async def getRelevantDocs(self,query:str,
|
74 |
"""This should also post the result to firebase"""
|
75 |
print("retriver state",self.retriever.search_kwargs)
|
76 |
print("retriver state",self.retriever.search_type)
|
77 |
-
|
|
|
|
|
|
|
|
|
78 |
retVal=await self.retriever.aget_relevant_documents(query)
|
79 |
value=[]
|
80 |
excludeMeta=True
|
@@ -125,10 +129,10 @@ class ChromaIntf():
|
|
125 |
with open("./docs/"+metadata['ID'],"w") as fd:
|
126 |
fd.write(inStr)
|
127 |
try:
|
128 |
-
return await self.vectorstore.
|
129 |
except:
|
130 |
print("inside expect of addText")
|
131 |
-
return await self.vectorstore.
|
132 |
|
133 |
async def listDocs(self):
|
134 |
collection=self.vectorstore._client.get_collection(self.vectorstore._LANGCHAIN_DEFAULT_COLLECTION_NAME,embedding_function=self.embedding)
|
|
|
70 |
)
|
71 |
|
72 |
|
73 |
+
async def getRelevantDocs(self,query:str,kwargs:dict):
|
74 |
"""This should also post the result to firebase"""
|
75 |
print("retriver state",self.retriever.search_kwargs)
|
76 |
print("retriver state",self.retriever.search_type)
|
77 |
+
try:
|
78 |
+
for key in kwargs.keys():
|
79 |
+
self.retriever.search_kwargs[key]=kwargs[key]
|
80 |
+
except:
|
81 |
+
print("setting search args failed")
|
82 |
retVal=await self.retriever.aget_relevant_documents(query)
|
83 |
value=[]
|
84 |
excludeMeta=True
|
|
|
129 |
with open("./docs/"+metadata['ID'],"w") as fd:
|
130 |
fd.write(inStr)
|
131 |
try:
|
132 |
+
return await self.vectorstore.aadd_documents(docs,ids=[metadata.ID])
|
133 |
except:
|
134 |
print("inside expect of addText")
|
135 |
+
return await self.vectorstore.aadd_documents(docs,ids=[metadata['ID']])
|
136 |
|
137 |
async def listDocs(self):
|
138 |
collection=self.vectorstore._client.get_collection(self.vectorstore._LANGCHAIN_DEFAULT_COLLECTION_NAME,embedding_function=self.embedding)
|
src/main.py
CHANGED
@@ -60,13 +60,14 @@ app.add_middleware(
|
|
60 |
api_base="/api/v1"
|
61 |
|
62 |
@app.post(api_base+"/getMatchingDocs")
|
63 |
-
async def get_matching_docs(inStr: str ) -> Any:
|
64 |
"""
|
65 |
Gets the query embeddings and uses metadata appropriately and gets the matching docs for query
|
66 |
TODO: Add parameter for type of query and number of docs to return
|
67 |
TODO: Add parameter to return the source information as well
|
68 |
"""
|
69 |
-
|
|
|
70 |
|
71 |
@app.post(api_base+"/addTextDocument")
|
72 |
async def add_text_document(inDoc: DocWithMeta ) -> Any:
|
|
|
60 |
api_base="/api/v1"
|
61 |
|
62 |
@app.post(api_base+"/getMatchingDocs")
|
63 |
+
async def get_matching_docs(inStr: str, kwargs: Dict [Any, Any] ) -> Any:
|
64 |
"""
|
65 |
Gets the query embeddings and uses metadata appropriately and gets the matching docs for query
|
66 |
TODO: Add parameter for type of query and number of docs to return
|
67 |
TODO: Add parameter to return the source information as well
|
68 |
"""
|
69 |
+
print("Reaching get matchin docs ")
|
70 |
+
return await chromaIntf.getRelevantDocs(inStr,kwargs)
|
71 |
|
72 |
@app.post(api_base+"/addTextDocument")
|
73 |
async def add_text_document(inDoc: DocWithMeta ) -> Any:
|