samarthputhraya commented on code in PR #1470:
URL: https://github.com/apache/flink-agents/pull/1470#discussion_r4735797070
##########
python/flink_agents/integrations/chat_models/openai/openai_chat_model.py:
##########
@@ -444,47 +464,74 @@ class OpenAIChatModelSetup(BaseChatModelSetup):
default=False,
description="Whether to use strict mode for invoking tools/using
schemas.",
)
- reasoning_effort: Literal["low", "medium", "high"] | None = Field(
+ reasoning_effort: _ReasoningEffort | None = Field(
default=None,
description="The effort to use for reasoning models.",
)
+ # The effort open() chose because none was configured, or None.
+ _default_reasoning_effort: _ReasoningEffort | None =
PrivateAttr(default=None)
def __init__(
self,
*,
model: str = DEFAULT_OPENAI_MODEL,
temperature: float = DEFAULT_TEMPERATURE,
- max_tokens: int | None = None,
+ max_completion_tokens: int | None = None,
additional_kwargs: Dict[str, Any] | None = None,
strict: bool = False,
- reasoning_effort: Literal["low", "medium", "high"] | None = None,
+ reasoning_effort: _ReasoningEffort | None = None,
**kwargs: Any,
) -> None:
"""Init method."""
additional_kwargs = additional_kwargs or {}
super().__init__(
model=model,
temperature=temperature,
- max_tokens=max_tokens,
+ max_completion_tokens=max_completion_tokens,
additional_kwargs=additional_kwargs,
strict=strict,
reasoning_effort=reasoning_effort,
**kwargs,
)
+ @override
+ def open(self) -> None:
+ """Resolve the connection, prompt and tools, then pick the default
+ ``reasoning_effort`` described on this class.
+
+ The default depends on the resolved tools, so it is chosen here rather
than
+ at construction.
+ """
+ super().open()
+ configured = (
+ self.reasoning_effort is not None
+ or "reasoning_effort" in self.additional_kwargs
+ )
+ if (
+ not configured
+ and self.tools
+ and self.model in _MODELS_CALLING_TOOLS_ONLY_WITHOUT_REASONING
Review Comment:
Good catch, thanks. Yes, it should follow the request, and dac124e now does
that in both languages. Python's `chat` and Java's `chat(messages, tools,
modelParams, outputSchema)` pick the default from the request's own model,
after the per-call arguments are merged, and from the tools that request
carries. `model_kwargs` and `getParameters()` now hold only a configured value.
So your case (a Luna setup with a tool, called with `model="gpt-6.2-sol"`)
sends no `reasoning_effort`, a `gpt-4o-mini` setup called with
`model="gpt-6-luna"` gets `"none"`, and a call that passes its own `tools`
decides by those. New tests on both sides cover these and fail on the previous
head. Java's openai module (218) and the Python OpenAI and vLLM tests (141)
pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]