From fcc6b41ab76af45b7fc79fbc279d4f08898c4a75 Mon Sep 17 00:00:00 2001 From: takatost Date: Thu, 31 Aug 2023 18:23:44 +0800 Subject: [PATCH] feat: decrease claude model request time by set max top_k to 10 (#1071) --- api/core/orchestrator_rule_parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/core/orchestrator_rule_parser.py b/api/core/orchestrator_rule_parser.py index 4f87e45e0d..310fb0ae15 100644 --- a/api/core/orchestrator_rule_parser.py +++ b/api/core/orchestrator_rule_parser.py @@ -283,6 +283,7 @@ class OrchestratorRuleParser: def _dynamic_calc_retrieve_k(cls, dataset: Dataset, rest_tokens: int) -> int: DEFAULT_K = 2 CONTEXT_TOKENS_PERCENT = 0.3 + MAX_K = 10 if rest_tokens == -1: return DEFAULT_K @@ -311,5 +312,5 @@ class OrchestratorRuleParser: if context_limit_tokens <= segment_max_tokens * DEFAULT_K: return DEFAULT_K - # Expand the k value when there's still some room left in the 30% rest tokens space - return context_limit_tokens // segment_max_tokens + # Expand the k value when there's still some room left in the 30% rest tokens space, but less than the MAX_K + return min(context_limit_tokens // segment_max_tokens, MAX_K)