-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__init__.py
More file actions
36 lines (29 loc) · 1.18 KB
/
__init__.py
File metadata and controls
36 lines (29 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""LangGraph 集成模块
使用 AgentRunConverter 将 LangGraph 事件转换为 AG-UI 协议事件:
>>> from agentrun.integration.langgraph import AgentRunConverter
>>>
>>> async def invoke_agent(request: AgentRequest):
... converter = AgentRunConverter()
... async for event in agent.astream_events(input_data, version="v2"):
... for item in converter.convert(event):
... yield item
或使用静态方法(无状态):
>>> from agentrun.integration.langgraph import AgentRunConverter
>>>
>>> async for event in agent.astream_events(input_data, version="v2"):
... for item in AgentRunConverter.to_agui_events(event):
... yield item
支持多种调用方式:
- agent.astream_events(input, version="v2") - 支持 token by token
- agent.stream(input, stream_mode="updates") - 按节点输出
- agent.astream(input, stream_mode="updates") - 异步按节点输出
"""
from .agent_converter import AgentRunConverter
from .builtin import knowledgebase_toolset, model, sandbox_toolset, toolset
__all__ = [
"AgentRunConverter",
"model",
"toolset",
"sandbox_toolset",
"knowledgebase_toolset",
]