From 2ac83df1e0d56e020e4a1284f5d9a2b62c65d4a0 Mon Sep 17 00:00:00 2001 From: bsiggel Date: Thu, 19 Mar 2026 09:50:31 +0000 Subject: [PATCH] fix: Update default chat model to grok-4-1-fast-reasoning and enhance logging for LLM responses --- services/langchain_xai_service.py | 6 +++--- steps/ai/chat_completions_api_step.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/services/langchain_xai_service.py b/services/langchain_xai_service.py index 28d0e99..273d74a 100644 --- a/services/langchain_xai_service.py +++ b/services/langchain_xai_service.py @@ -17,7 +17,7 @@ class LangChainXAIService: Usage: service = LangChainXAIService(ctx) - model = service.get_chat_model(model="grok-2-latest") + model = service.get_chat_model(model="grok-4-1-fast-reasoning") model_with_tools = service.bind_file_search(model, collection_id) result = await service.invoke_chat(model_with_tools, messages) """ @@ -46,7 +46,7 @@ class LangChainXAIService: def get_chat_model( self, - model: str = "grok-2-latest", + model: str = "grok-4-1-fast-reasoning", temperature: float = 0.7, max_tokens: Optional[int] = None ): @@ -54,7 +54,7 @@ class LangChainXAIService: Initialisiert ChatXAI Model. Args: - model: Model name (default: grok-2-latest) + model: Model name (default: grok-4-1-fast-reasoning) temperature: Sampling temperature 0.0-1.0 max_tokens: Optional max tokens for response diff --git a/steps/ai/chat_completions_api_step.py b/steps/ai/chat_completions_api_step.py index f98f5bd..1f9bb61 100644 --- a/steps/ai/chat_completions_api_step.py +++ b/steps/ai/chat_completions_api_step.py @@ -317,6 +317,18 @@ async def invoke_and_format_response( "total_tokens": getattr(u, 'input_tokens', 0) + getattr(u, 'output_tokens', 0) } + # Log complete LLM response + ctx.logger.info("=" * 80) + ctx.logger.info("📤 LLM RESPONSE") + ctx.logger.info("-" * 80) + ctx.logger.info(f"Model: {model_name}") + ctx.logger.info(f"Completion ID: {completion_id}") + ctx.logger.info(f"Usage: {usage['prompt_tokens']} prompt + {usage['completion_tokens']} completion = {usage['total_tokens']} total tokens") + ctx.logger.info("-" * 80) + ctx.logger.info("Content:") + ctx.logger.info(content) + ctx.logger.info("=" * 80) + # Format OpenAI-compatible response response_body = { 'id': completion_id,