mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 13:40:55 +00:00
feat: vectordb query error handling
This commit is contained in:
parent
ad3d69be30
commit
142269374f
@ -85,12 +85,19 @@ async def get_status():
|
|||||||
|
|
||||||
@app.get("/query/{collection_name}")
|
@app.get("/query/{collection_name}")
|
||||||
def query_collection(collection_name: str, query: str, k: Optional[int] = 4):
|
def query_collection(collection_name: str, query: str, k: Optional[int] = 4):
|
||||||
|
try:
|
||||||
collection = CHROMA_CLIENT.get_collection(
|
collection = CHROMA_CLIENT.get_collection(
|
||||||
name=collection_name,
|
name=collection_name,
|
||||||
)
|
)
|
||||||
result = collection.query(query_texts=[query], n_results=k)
|
result = collection.query(query_texts=[query], n_results=k)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
|
detail=ERROR_MESSAGES.DEFAULT(e),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.post("/web")
|
@app.post("/web")
|
||||||
|
Loading…
Reference in New Issue
Block a user