Spaces:
Runtime error
Runtime error
v0.1.2
Browse files- src/baseInfra/dbInterface.py +1 -0
- src/main.py +18 -1
src/baseInfra/dbInterface.py
CHANGED
@@ -89,6 +89,7 @@ class DbInterface:
|
|
89 |
# retVal=True
|
90 |
# #cache.append({'input':input,'value':value})
|
91 |
cache={'input':input,'value':value}
|
|
|
92 |
fb.patch(self.base_dir+"/"+self.cache_loc, {fb_key:cache})
|
93 |
return retVal
|
94 |
|
|
|
89 |
# retVal=True
|
90 |
# #cache.append({'input':input,'value':value})
|
91 |
cache={'input':input,'value':value}
|
92 |
+
print(f"Adding to cache the results {value} for {input}")
|
93 |
fb.patch(self.base_dir+"/"+self.cache_loc, {fb_key:cache})
|
94 |
return retVal
|
95 |
|
src/main.py
CHANGED
@@ -77,6 +77,23 @@ async def get_matching_docs(inStr: str, kwargs: Dict [Any, Any] ,background_task
|
|
77 |
logger.info("================================================")
|
78 |
return retVal
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
@app.post(api_base+"/addTextDocument")
|
81 |
async def add_text_document(inDoc: DocWithMeta ) -> Any:
|
82 |
"""
|
@@ -122,5 +139,5 @@ async def list_docs():
|
|
122 |
print(__name__)
|
123 |
|
124 |
if __name__ == '__main__' or __name__ == "src.main":
|
125 |
-
uvicorn.run(f"{Path(__file__).stem}:app", host="0.0.0.0", port=8000,workers=
|
126 |
#uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
77 |
logger.info("================================================")
|
78 |
return retVal
|
79 |
|
80 |
+
@app.post(api_base+"/getMatchingDocsSync")
|
81 |
+
async def get_matching_docs_sync(inStr: str, kwargs: Dict [Any, Any]) -> Any:
|
82 |
+
"""
|
83 |
+
Gets the query embeddings and uses metadata appropriately and gets the matching docs for query
|
84 |
+
This is synchronous version
|
85 |
+
TODO: Add parameter for type of query and number of docs to return
|
86 |
+
TODO: Add parameter to return the source information as well
|
87 |
+
"""
|
88 |
+
logger.info("================================================")
|
89 |
+
logger.info("Received new request at /getMatchingDocs:"+inStr)
|
90 |
+
retVal=await chromaIntf.getRelevantDocs(inStr,kwargs)
|
91 |
+
#background_tasks.add_task(chromaIntf.getRelevantDocs,inStr,kwargs)
|
92 |
+
#retVal="added to queue"
|
93 |
+
logger.info("Returning:"+retVal)
|
94 |
+
logger.info("================================================")
|
95 |
+
return retVal
|
96 |
+
|
97 |
@app.post(api_base+"/addTextDocument")
|
98 |
async def add_text_document(inDoc: DocWithMeta ) -> Any:
|
99 |
"""
|
|
|
139 |
print(__name__)
|
140 |
|
141 |
if __name__ == '__main__' or __name__ == "src.main":
|
142 |
+
uvicorn.run(f"{Path(__file__).stem}:app", host="0.0.0.0", port=8000,workers=1)
|
143 |
#uvicorn.run(app, host="0.0.0.0", port=8000)
|