Añadir completion + ajustes del chat

This commit is contained in:
Jordan Diaz
2026-04-14 07:12:50 +00:00
parent 15abc1eb4f
commit 469ff65052
3 changed files with 229 additions and 56 deletions

View File

@@ -152,6 +152,14 @@ class OpenAIAdapter(ModelAdapter):
}
if tools:
kwargs["tools"] = self._format_tools(tools)
# Fuerza al modelo a usar un tool concreto para garantizar JSON por schema
# (usado por /completions con json_schema). Ver ClaudeAdapter para la variante.
force_tool = (config.extra or {}).get("force_tool")
if force_tool:
kwargs["tool_choice"] = {
"type": "function",
"function": {"name": force_tool},
}
response = await self._client.chat.completions.create(**kwargs)
choice = response.choices[0]