mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
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.
This commit is contained in:
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user