From 45e04cb45f09af956083976848d6f5966b86f70d Mon Sep 17 00:00:00 2001 From: Aisuko Date: Sat, 27 Jul 2024 09:58:01 +1000 Subject: [PATCH] fix none context cause crash Signed-off-by: Aisuko --- Makefile | 2 +- backend/src/repository/rag/chat.py | 2 +- backend/tests/unit_tests/test_api_version.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7c529bf..cd90bbf 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ DEBUG:=True BACKEND_SERVER_HOST:=127.0.0.1 BACKEND_SERVER_PORT:=8000 BACKEND_SERVER_WORKERS:=4 -BACKEND_SERVER_VERSION:=v0.1.17 +BACKEND_SERVER_VERSION:=v0.1.18 TIMEZONE:="UTC" # Database - Postgres diff --git a/backend/src/repository/rag/chat.py b/backend/src/repository/rag/chat.py index 470aca9..7b8f319 100644 --- a/backend/src/repository/rag/chat.py +++ b/backend/src/repository/rag/chat.py @@ -142,7 +142,7 @@ async def get_context_by_question(input_msg: str): context = vector_db.search( list(embedd_input), 1, collection_name=DatasetFormatter.format_dataset_by_name(collection_name) ) - if len(context) > 0: + if context and (len(context) > 0): context = f"Please answer the question based on answer {context[0]}" else: context = InferenceHelper.instruction diff --git a/backend/tests/unit_tests/test_api_version.py b/backend/tests/unit_tests/test_api_version.py index 5d27047..9969243 100644 --- a/backend/tests/unit_tests/test_api_version.py +++ b/backend/tests/unit_tests/test_api_version.py @@ -43,5 +43,5 @@ def test_api_version(self): assert response.json() == { "inferenceEngine": "server--b1-2321a5e", "milvus": "v2.3.12", - "kirin": "v0.1.17", + "kirin": "v0.1.18", }