fix: count history tokens from chunks, remove old UI setting limit (#2196)

This commit is contained in:
Alex
2025-12-17 01:34:17 +00:00
committed by GitHub
parent aacf281222
commit af3e16c4fc
12 changed files with 3 additions and 77 deletions

View File

@@ -77,11 +77,11 @@ def count_tokens_docs(docs):
def calculate_doc_token_budget(
model_id: str = "gpt-4o", history_token_limit: int = 2000
model_id: str = "gpt-4o"
) -> int:
total_context = get_token_limit(model_id)
reserved = sum(settings.RESERVED_TOKENS.values())
doc_budget = total_context - history_token_limit - reserved
doc_budget = total_context - reserved
return max(doc_budget, 1000)