From ec93c8b0b8cd8f60ea1a4edc2d12dea236d5693e Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 17 Dec 2024 10:54:31 +0330 Subject: [PATCH] feat: code cleaning! added other variables as global variable --- utils/globals.py | 1 + utils/query_engine/prepare_answer_sources.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/globals.py b/utils/globals.py index d9bf8be..aa558f7 100644 --- a/utils/globals.py +++ b/utils/globals.py @@ -1,5 +1,6 @@ # the theshold to skip nodes of being included in an answer RETRIEVER_THRESHOLD = 0.4 +REFERENCE_SCORE_THRESHOLD = 0.5 INVALID_QUERY_RESPONSE = ( "We're unable to process your query. Please refine it and try again." ) diff --git a/utils/query_engine/prepare_answer_sources.py b/utils/query_engine/prepare_answer_sources.py index a0091ad..5e443cf 100644 --- a/utils/query_engine/prepare_answer_sources.py +++ b/utils/query_engine/prepare_answer_sources.py @@ -1,17 +1,20 @@ import logging from llama_index.core.schema import NodeWithScore +from utils.globals import REFERENCE_SCORE_THRESHOLD class PrepareAnswerSources: - def __init__(self, threshold: float = 0.5, max_refs_per_source: int = 3) -> None: + def __init__( + self, threshold: float = REFERENCE_SCORE_THRESHOLD, max_refs_per_source: int = 3 + ) -> None: """ Initialize the PrepareAnswerSources class. Parameters ---------- threshold : float, optional - Minimum score threshold for including a node's URL, by default 0.5 + Minimum score threshold for including a node's URL, by default 0.5 set in globals file max_refs_per_source : int, optional Maximum number of references to include per data source, by default 3 """