From 75d105f636f465fd3a788ec017629ea636beccf9 Mon Sep 17 00:00:00 2001 From: "a.arystanbek" Date: Sun, 30 Aug 2026 20:37:35 +0000 Subject: [PATCH] fix: support GPT-5 request contract (max_completion_tokens, reasoning_effort) and switch aimaq voice decisions to gpt-5-nano --- deployment/aimaq.env.production | 6 +++--- services/ai_orchestrator_service/app.py | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/deployment/aimaq.env.production b/deployment/aimaq.env.production index 87c28cb..cf97bb8 100644 --- a/deployment/aimaq.env.production +++ b/deployment/aimaq.env.production @@ -10,10 +10,10 @@ ALLOW_LEGACY_HEADER_AUTH=0 AI_PROVIDER=openai_compatible AI_API_BASE=https://api.openai.com/v1 -AI_API_KEY=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 -AI_MODEL=gpt-4o-mini +AI_API_KEY=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 +AI_MODEL=gpt-5-nano AI_TIMEOUT_SECONDS=30 -AI_VOICE_AI_TIMEOUT_SECONDS=10 +AI_VOICE_AI_TIMEOUT_SECONDS=15 AI_WEB_SEARCH_ENABLED=1 AI_WEB_SEARCH_MAX_RESULTS=5 AI_WEB_SEARCH_GL=kz diff --git a/services/ai_orchestrator_service/app.py b/services/ai_orchestrator_service/app.py index b3111cf..603763f 100644 --- a/services/ai_orchestrator_service/app.py +++ b/services/ai_orchestrator_service/app.py @@ -2357,13 +2357,18 @@ def _request_structured_model_decision( if not _ai_api_base() or not _ai_api_key(): raise RuntimeError("AI_API_BASE / AI_API_KEY are required for openai_compatible provider") started = time.perf_counter() - payload = { - "model": _ai_model(), - "temperature": 0.2, - "max_tokens": _ai_decision_max_tokens(), + model = _ai_model() + payload: dict[str, Any] = { + "model": model, "response_format": {"type": "json_object"}, "messages": messages, } + if model.startswith("gpt-5"): + payload["max_completion_tokens"] = _ai_decision_max_tokens() + payload["reasoning_effort"] = "minimal" + else: + payload["temperature"] = 0.2 + payload["max_tokens"] = _ai_decision_max_tokens() effective_timeout = timeout_seconds if timeout_seconds is not None else _ai_timeout_seconds() with httpx.Client(timeout=effective_timeout) as client: response = client.post(