mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-12 16:23:26 +00:00
feat: update text and text_ids value is ""
This commit is contained in:
@ -122,7 +122,7 @@ class ChromaUpsert(Blackbox):
|
||||
|
||||
response_file = f"\n{file} ids is 0~{len(docs)-1}"
|
||||
|
||||
if text is not None and text_ids is not None:
|
||||
if text != "" and text_ids != "":
|
||||
Chroma.from_texts(texts=[text], embedding=embedding_model, ids=[text_ids], collection_name=chroma_collection_id, client=client)
|
||||
|
||||
response_string = f"\n{text} ids is {text_ids}"
|
||||
@ -140,8 +140,8 @@ class ChromaUpsert(Blackbox):
|
||||
async def fast_api_handler(self, request: Request) -> Response:
|
||||
|
||||
user_file = (await request.form()).get("file")
|
||||
user_text = (await request.form()).get("text")
|
||||
user_text_ids = (await request.form()).get("text_ids")
|
||||
user_text = (await request.form()).get("text", "")
|
||||
user_text_ids = (await request.form()).get("text_ids", "")
|
||||
setting: dict = (await request.form()).get("settings")
|
||||
|
||||
if isinstance(setting, str):
|
||||
@ -150,13 +150,13 @@ class ChromaUpsert(Blackbox):
|
||||
except json.JSONDecodeError:
|
||||
return JSONResponse(content={"error": "Invalid settings format"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
if user_file is None and user_text is None:
|
||||
if user_file is None and user_text == "":
|
||||
return JSONResponse(content={"error": "file or text is required"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
if user_text is not None and user_text_ids is None:
|
||||
|
||||
if user_text != "" and user_text_ids == "":
|
||||
return JSONResponse(content={"error": "text_ids is required when text is provided"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
if user_file is not None and user_file.size != 0:
|
||||
if user_file != None and user_file.size != 0:
|
||||
pdf_bytes = await user_file.read()
|
||||
|
||||
custom_filename = user_file.filename
|
||||
|
||||
Reference in New Issue
Block a user