fix: openai llm model name is unknown (#3422)

This commit is contained in:
Himanshu Gunwant
2026-01-13 22:25:52 +05:30
committed by GitHub
parent ae59b3ba36
commit d0f227189c
2 changed files with 5 additions and 3 deletions

1
changelog/3422.fixed.md Normal file
View File

@@ -0,0 +1 @@
- Fixed a bug in `traced_llm` where the model name in opentelemetry is shown unknown even though it is defined.

View File

@@ -483,9 +483,10 @@ def traced_llm(func: Optional[Callable] = None, *, name: Optional[str] = None) -
# Add all available attributes to the span
attribute_kwargs = {
"service_name": service_class_name,
"model": getattr(
self, getattr(self, "_full_model_name", "model_name"), "unknown"
),
"model": getattr(self, "_full_model_name", None)
or getattr(self, "model_name", None)
or params.get("model")
or "unknown",
"stream": True, # Most LLM services use streaming
"parameters": params,
}