From 7bbe8d862822958d43ae43f753b57dbe3bbe806c Mon Sep 17 00:00:00 2001 From: Sakshi Gupta <64280320+sakshi1989@users.noreply.github.com> Date: Tue, 9 Sep 2025 11:43:42 -0400 Subject: [PATCH] docs: Update graph-api.md for "Extended example: specifying LLM at runtime" (#5938) docs (graphapi) : Handle Missing Context in LLM Invocation - Invoking the LLM without explicitly passing a context parameter resulted in the following error: `AttributeError: 'NoneType' object has no attribute 'model_provider'` This occurred because the context was None, and the system attempted to access model_provider. This PR ensures that when context is not provided, an empty context is passed explicitly. This allows the system to correctly fall back to the default value defined in the ContextSchema.model_provider attribute. --- docs/docs/how-tos/graph-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/how-tos/graph-api.md b/docs/docs/how-tos/graph-api.md index c92f45dcc..7fbd084c8 100644 --- a/docs/docs/how-tos/graph-api.md +++ b/docs/docs/how-tos/graph-api.md @@ -1019,7 +1019,7 @@ console.log(await graph.invoke({}, { configurable: { myRuntimeValue: "b" } })); # Usage input_message = {"role": "user", "content": "hi"} # With no configuration, uses default (Anthropic) - response_1 = graph.invoke({"messages": [input_message]})["messages"][-1] + response_1 = graph.invoke({"messages": [input_message]}, context=ContextSchema())["messages"][-1] # Or, can set OpenAI response_2 = graph.invoke({"messages": [input_message]}, context={"model_provider": "openai"})["messages"][-1]