fix(ollama): trace invoke model override (#37502)

If you override the model at invoke time — e.g. `chat.invoke(messages,
model="llama3.2")` or `chat.bind(model="llama3.2")` - traces previously
logged the model the `ChatOllama` instance was constructed with, not the
one that ran. Tracing now reflects the runtime override, so dashboards,
filters, and cost/latency breakdowns line up with what really executed.
This commit is contained in:
Mason Daugherty
2026-05-18 11:51:35 -07:00
committed by GitHub
parent 992c613b51
commit 0346ac0fa2

View File

@@ -1186,7 +1186,7 @@ class ChatOllama(BaseChatModel):
params = self._get_invocation_params(stop=stop, **kwargs)
ls_params = LangSmithParams(
ls_provider="ollama",
ls_model_name=self.model,
ls_model_name=params.get("model", self.model),
ls_model_type="chat",
ls_temperature=params.get("temperature", self.temperature),
)