Spaces:
Runtime error
Runtime error
v0.1.1
Browse files- src/main.py +16 -6
src/main.py
CHANGED
|
@@ -16,7 +16,9 @@ from typing import List, Dict, Any, Generator, Optional, cast, Callable
|
|
| 16 |
from chromaIntf import ChromaIntf
|
| 17 |
import baseInfra.dropbox_handler as dbh
|
| 18 |
import traceback
|
|
|
|
| 19 |
|
|
|
|
| 20 |
chromaIntf=ChromaIntf()
|
| 21 |
|
| 22 |
class PathRequest(BaseModel):
|
|
@@ -66,17 +68,24 @@ async def get_matching_docs(inStr: str, kwargs: Dict [Any, Any] ,background_task
|
|
| 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 |
|
| 72 |
@app.post(api_base+"/addTextDocument")
|
| 73 |
async def add_text_document(inDoc: DocWithMeta ) -> Any:
|
| 74 |
"""
|
| 75 |
Add text and metadata to the db
|
| 76 |
"""
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
@app.get(api_base+"/persist")
|
| 82 |
async def persist_db():
|
|
@@ -111,4 +120,5 @@ async def list_docs():
|
|
| 111 |
print(__name__)
|
| 112 |
|
| 113 |
if __name__ == '__main__' or __name__ == "src.main":
|
| 114 |
-
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
|
|
|
| 16 |
from chromaIntf import ChromaIntf
|
| 17 |
import baseInfra.dropbox_handler as dbh
|
| 18 |
import traceback
|
| 19 |
+
from pathlib import Path
|
| 20 |
|
| 21 |
+
logger=logging.getLogger("root")
|
| 22 |
chromaIntf=ChromaIntf()
|
| 23 |
|
| 24 |
class PathRequest(BaseModel):
|
|
|
|
| 68 |
TODO: Add parameter for type of query and number of docs to return
|
| 69 |
TODO: Add parameter to return the source information as well
|
| 70 |
"""
|
| 71 |
+
logger.info("================================================")
|
| 72 |
+
logger.info("Received new request at /getMatchingDocs:"+inStr)
|
| 73 |
+
retVal=await chromaIntf.getRelevantDocs(inStr,kwargs)
|
| 74 |
+
logger.info("Returning:"+retVal)
|
| 75 |
+
logger.info("================================================")
|
| 76 |
+
return retVal
|
| 77 |
|
| 78 |
@app.post(api_base+"/addTextDocument")
|
| 79 |
async def add_text_document(inDoc: DocWithMeta ) -> Any:
|
| 80 |
"""
|
| 81 |
Add text and metadata to the db
|
| 82 |
"""
|
| 83 |
+
logger.info("================================================")
|
| 84 |
+
logger.info("Received new request at /addTextDocuments:"+inDoc)
|
| 85 |
+
retVal= await chromaIntf.addText(inDoc.text,inDoc.metadata)
|
| 86 |
+
logger.info("Returning:"+retVal)
|
| 87 |
+
logger.info("================================================")
|
| 88 |
+
return retVal
|
| 89 |
|
| 90 |
@app.get(api_base+"/persist")
|
| 91 |
async def persist_db():
|
|
|
|
| 120 |
print(__name__)
|
| 121 |
|
| 122 |
if __name__ == '__main__' or __name__ == "src.main":
|
| 123 |
+
uvicorn.run(f"{Path(__file__).stem}:app", host="0.0.0.0", port=8000,workers=4)
|
| 124 |
+
#uvicorn.run(app, host="0.0.0.0", port=8000)
|