javascript
导入
from dataclasses import dataclass
kotlin
# 1. 定义运行时上下文类型
@dataclass
class UserContext:
username: str
ini
# 在节点内获取使用
def llm_node(state: OverAllState, runtime: Runtime[UserContext]) -> OverAllState:
runtime_context = runtime.context
...
...
ini
# 构建state时传入content类
builder = StateGraph(state_schema=OverAllState, context_schema=UserContext)
arduino
# 发起时传入content实例
res = graph.invoke( {"user_input": "你好,帮我查一下我有哪些资产"}, config=config, context=UserContext(username="Alice") )