fix: prefer _full_model_name over _settings.model in tracing
The API-provided full model name is more specific than the user-provided model name (e.g. includes version/snapshot details). Reorder the lookup in _get_model_name and add a comment where the Responses service sets the field.
This commit is contained in:
committed by
Mark Backman
parent
3ddb7b4aaf
commit
f680f3c1fa
@@ -292,6 +292,8 @@ class OpenAIResponsesLLMService(LLMService):
|
|||||||
|
|
||||||
model = getattr(response, "model", None)
|
model = getattr(response, "model", None)
|
||||||
if model:
|
if model:
|
||||||
|
# This field is used by @traced_llm for more detailed
|
||||||
|
# model name in tracing spans
|
||||||
self._full_model_name = model
|
self._full_model_name = model
|
||||||
|
|
||||||
# Process any function calls
|
# Process any function calls
|
||||||
|
|||||||
@@ -51,8 +51,10 @@ def _get_model_name(service) -> str:
|
|||||||
check all the places we used to store it.
|
check all the places we used to store it.
|
||||||
"""
|
"""
|
||||||
return (
|
return (
|
||||||
getattr(getattr(service, "_settings", None), "model", None)
|
# Some services store an API-response-provided detailed "full" name,
|
||||||
or getattr(service, "_full_model_name", None)
|
# which is distinct from the user-provided model name
|
||||||
|
getattr(service, "_full_model_name", None)
|
||||||
|
or getattr(getattr(service, "_settings", None), "model", None)
|
||||||
or getattr(service, "model_name", None)
|
or getattr(service, "model_name", None)
|
||||||
or getattr(service, "_model_name", None)
|
or getattr(service, "_model_name", None)
|
||||||
or "unknown"
|
or "unknown"
|
||||||
|
|||||||
Reference in New Issue
Block a user