From 3a7f2a180d677c84debe40b31852510448289aeb Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 3 Dec 2024 10:35:10 +0330 Subject: [PATCH 1/2] feat: lowering references threshold to 0.5! --- routers/amqp.py | 2 +- utils/query_engine/prepare_answer_sources.py | 2 +- worker/tasks.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/amqp.py b/routers/amqp.py index b58a9a4..bf6a93f 100644 --- a/routers/amqp.py +++ b/routers/amqp.py @@ -35,7 +35,7 @@ async def ask(payload: Payload, logger: Logger): response, references = query_data_sources( community_id=community_id, query=question ) - prepare_answer = PrepareAnswerSources(threshold=0.7) + prepare_answer = PrepareAnswerSources() answer_reference = prepare_answer.prepare_answer_sources(nodes=references) logger.info(f"COMMUNITY_ID: {community_id} Job finished") diff --git a/utils/query_engine/prepare_answer_sources.py b/utils/query_engine/prepare_answer_sources.py index 1d735b0..e050211 100644 --- a/utils/query_engine/prepare_answer_sources.py +++ b/utils/query_engine/prepare_answer_sources.py @@ -4,7 +4,7 @@ class PrepareAnswerSources: - def __init__(self, threshold: float = 0.7) -> None: + def __init__(self, threshold: float = 0.5) -> None: self.threshold = threshold def prepare_answer_sources(self, nodes: list[NodeWithScore]) -> str: diff --git a/worker/tasks.py b/worker/tasks.py index 26fa71a..8042134 100644 --- a/worker/tasks.py +++ b/worker/tasks.py @@ -19,7 +19,7 @@ def ask_question_auto_search( response, references = query_data_sources( community_id=community_id, query=query ) - answer_sources = PrepareAnswerSources(threshold=0.7).prepare_answer_sources( + answer_sources = PrepareAnswerSources().prepare_answer_sources( nodes=references ) except Exception: From 2496c2d13f51e0286d510cce77c8beb0df190366 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 3 Dec 2024 10:42:37 +0330 Subject: [PATCH 2/2] fix: black linter issues! --- worker/tasks.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/worker/tasks.py b/worker/tasks.py index 8042134..346f542 100644 --- a/worker/tasks.py +++ b/worker/tasks.py @@ -19,9 +19,7 @@ def ask_question_auto_search( response, references = query_data_sources( community_id=community_id, query=query ) - answer_sources = PrepareAnswerSources().prepare_answer_sources( - nodes=references - ) + answer_sources = PrepareAnswerSources().prepare_answer_sources(nodes=references) except Exception: response = "Sorry, We cannot process your question at the moment." answer_sources = None