Skip to content

Commit 0b7c3f7

Browse files
refactor: promote _is_reasoning_model and _resolve_model_name to public API
Remove underscore prefix from helper functions in agent_builder.py to make them part of the supported public API, eliminating fragile cross-module dependency on private internals from map_handler.py. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 83e189a commit 0b7c3f7

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/ContentProcessor/src/libs/agent_framework/agent_builder.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
_REASONING_MODEL_PREFIXES = ("o1", "o3", "o4", "gpt-5")
3535

3636

37-
def _is_reasoning_model(model_name: str) -> bool:
37+
def is_reasoning_model(model_name: str) -> bool:
3838
"""Check if a model is a reasoning model based on its deployment name."""
3939
name = model_name.lower()
4040
return any(name.startswith(prefix) for prefix in _REASONING_MODEL_PREFIXES)
4141

4242

43-
def _resolve_model_name(client: Any, model_id: str | None = None) -> str | None:
43+
def resolve_model_name(client: Any, model_id: str | None = None) -> str | None:
4444
"""Extract model/deployment name from the client or explicit model_id."""
4545
if model_id:
4646
return model_id
@@ -55,7 +55,7 @@ def _strip_unsupported_reasoning_params(
5555
options: dict[str, Any], model_name: str | None
5656
) -> dict[str, Any]:
5757
"""Remove temperature and top_p for reasoning models that don't support them."""
58-
if model_name and _is_reasoning_model(model_name):
58+
if model_name and is_reasoning_model(model_name):
5959
removed = []
6060
for param in ("temperature", "top_p"):
6161
if param in options:
@@ -525,7 +525,7 @@ def build(self) -> Agent:
525525
if self._additional_chat_options:
526526
options.update(self._additional_chat_options)
527527

528-
model_name = _resolve_model_name(self._chat_client, self._model_id)
528+
model_name = resolve_model_name(self._chat_client, self._model_id)
529529
_strip_unsupported_reasoning_params(options, model_name)
530530

531531
default_options: ChatOptions | None = ChatOptions(**options) if options else None
@@ -866,7 +866,7 @@ def create_agent(
866866
if additional_chat_options:
867867
options.update(additional_chat_options)
868868

869-
model_name = _resolve_model_name(chat_client, model_id)
869+
model_name = resolve_model_name(chat_client, model_id)
870870
_strip_unsupported_reasoning_params(options, model_name)
871871

872872
default_options: ChatOptions | None = ChatOptions(**options) if options else None

src/ContentProcessor/src/libs/pipeline/handlers/map_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from agent_framework import Content, Message
1818
from pdf2image import convert_from_bytes
1919

20-
from libs.agent_framework.agent_builder import AgentBuilder, _is_reasoning_model, _resolve_model_name
20+
from libs.agent_framework.agent_builder import AgentBuilder, is_reasoning_model, resolve_model_name
2121
from libs.agent_framework.agent_framework_helper import AgentFrameworkHelper
2222
from libs.agent_framework.azure_openai_response_retry import ContextTrimConfig
2323
from libs.application.application_context import AppContext
@@ -256,8 +256,8 @@ async def execute(self, context: MessageContext) -> StepResult:
256256
)
257257

258258
# logprobs is not supported by reasoning models (o1, o3, gpt-5.x)
259-
model_name = _resolve_model_name(agent_client)
260-
if model_name and _is_reasoning_model(model_name):
259+
model_name = resolve_model_name(agent_client)
260+
if model_name and is_reasoning_model(model_name):
261261
run_options = {}
262262
else:
263263
run_options = {"logprobs": True, "top_logprobs": 5}

0 commit comments

Comments
 (0)