From 2d1f58a8a4c3bfc35a8cad58d132150823d116f7 Mon Sep 17 00:00:00 2001 From: GdoongMathew Date: Sat, 18 Jul 2026 12:08:44 +0800 Subject: [PATCH 1/2] update `input_too_large` threshold update `input_too_large` threshold (#2) (cherry picked from commit 149c6eba2624ca6e10c79ac1360a10f929003227) --- api/simple_chat.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/simple_chat.py b/api/simple_chat.py index e93199397..48fbe2b79 100644 --- a/api/simple_chat.py +++ b/api/simple_chat.py @@ -19,7 +19,7 @@ from api.bedrock_client import BedrockClient from api.azureai_client import AzureAIClient from api.dashscope_client import DashscopeClient -from api.rag import RAG +from api.rag import RAG, MAX_INPUT_TOKENS from api.prompts import ( DEEP_RESEARCH_FIRST_ITERATION_PROMPT, DEEP_RESEARCH_FINAL_ITERATION_PROMPT, @@ -88,8 +88,8 @@ async def chat_completions_stream(request: ChatCompletionRequest): if hasattr(last_message, 'content') and last_message.content: tokens = count_tokens(last_message.content, request.provider == "ollama") logger.info(f"Request size: {tokens} tokens") - if tokens > 8000: - logger.warning(f"Request exceeds recommended token limit ({tokens} > 7500)") + if tokens > MAX_INPUT_TOKENS: + logger.warning(f"Request exceeds recommended token limit ({tokens} > {MAX_INPUT_TOKENS})") input_too_large = True # Create a new RAG instance for this request From ee1b29cfb82362ba6741a49f148c191bedb7657a Mon Sep 17 00:00:00 2001 From: GdoongMathew Date: Sat, 18 Jul 2026 13:04:39 +0800 Subject: [PATCH 2/2] update `input_too_large` threshold --- api/websocket_wiki.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/websocket_wiki.py b/api/websocket_wiki.py index 7064f54b4..b3c15dd59 100644 --- a/api/websocket_wiki.py +++ b/api/websocket_wiki.py @@ -25,7 +25,7 @@ from api.openrouter_client import OpenRouterClient from api.azureai_client import AzureAIClient from api.dashscope_client import DashscopeClient -from api.rag import RAG +from api.rag import RAG, MAX_INPUT_TOKENS # Configure logging from api.logging_config import setup_logging @@ -81,8 +81,8 @@ async def handle_websocket_chat(websocket: WebSocket): if hasattr(last_message, 'content') and last_message.content: tokens = count_tokens(last_message.content, request.provider == "ollama") logger.info(f"Request size: {tokens} tokens") - if tokens > 8000: - logger.warning(f"Request exceeds recommended token limit ({tokens} > 7500)") + if tokens > MAX_INPUT_TOKENS: + logger.warning(f"Request exceeds recommended token limit ({tokens} > {MAX_INPUT_TOKENS})") input_too_large = True # Create a new RAG instance for this request