diff --git a/api/simple_chat.py b/api/simple_chat.py index 9076f71ab..749d2ebe6 100644 --- a/api/simple_chat.py +++ b/api/simple_chat.py @@ -11,7 +11,7 @@ from api.chat import ChatStreamer, prompt_builder, is_token_limit_error from api.config import get_model_config, configs from api.data_pipeline import count_tokens, get_file_content -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, @@ -78,8 +78,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 diff --git a/api/websocket_wiki.py b/api/websocket_wiki.py index 2d7e45b71..2b7d17b85 100644 --- a/api/websocket_wiki.py +++ b/api/websocket_wiki.py @@ -13,7 +13,7 @@ configs, ) from api.data_pipeline import count_tokens, get_file_content -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, @@ -75,8 +75,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