agentrun-inner-test 0.0.46__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentrun/__init__.py +325 -0
- agentrun/agent_runtime/__client_async_template.py +466 -0
- agentrun/agent_runtime/__endpoint_async_template.py +345 -0
- agentrun/agent_runtime/__init__.py +53 -0
- agentrun/agent_runtime/__runtime_async_template.py +477 -0
- agentrun/agent_runtime/api/__data_async_template.py +58 -0
- agentrun/agent_runtime/api/__init__.py +6 -0
- agentrun/agent_runtime/api/control.py +1362 -0
- agentrun/agent_runtime/api/data.py +98 -0
- agentrun/agent_runtime/client.py +868 -0
- agentrun/agent_runtime/endpoint.py +649 -0
- agentrun/agent_runtime/model.py +362 -0
- agentrun/agent_runtime/runtime.py +904 -0
- agentrun/credential/__client_async_template.py +177 -0
- agentrun/credential/__credential_async_template.py +216 -0
- agentrun/credential/__init__.py +28 -0
- agentrun/credential/api/__init__.py +5 -0
- agentrun/credential/api/control.py +606 -0
- agentrun/credential/client.py +319 -0
- agentrun/credential/credential.py +381 -0
- agentrun/credential/model.py +248 -0
- agentrun/integration/__init__.py +21 -0
- agentrun/integration/agentscope/__init__.py +12 -0
- agentrun/integration/agentscope/adapter.py +17 -0
- agentrun/integration/agentscope/builtin.py +65 -0
- agentrun/integration/agentscope/message_adapter.py +185 -0
- agentrun/integration/agentscope/model_adapter.py +60 -0
- agentrun/integration/agentscope/tool_adapter.py +59 -0
- agentrun/integration/builtin/__init__.py +16 -0
- agentrun/integration/builtin/model.py +93 -0
- agentrun/integration/builtin/sandbox.py +1234 -0
- agentrun/integration/builtin/toolset.py +47 -0
- agentrun/integration/crewai/__init__.py +12 -0
- agentrun/integration/crewai/adapter.py +9 -0
- agentrun/integration/crewai/builtin.py +65 -0
- agentrun/integration/crewai/model_adapter.py +31 -0
- agentrun/integration/crewai/tool_adapter.py +26 -0
- agentrun/integration/google_adk/__init__.py +12 -0
- agentrun/integration/google_adk/adapter.py +15 -0
- agentrun/integration/google_adk/builtin.py +65 -0
- agentrun/integration/google_adk/message_adapter.py +144 -0
- agentrun/integration/google_adk/model_adapter.py +46 -0
- agentrun/integration/google_adk/tool_adapter.py +235 -0
- agentrun/integration/langchain/__init__.py +30 -0
- agentrun/integration/langchain/adapter.py +15 -0
- agentrun/integration/langchain/builtin.py +71 -0
- agentrun/integration/langchain/message_adapter.py +141 -0
- agentrun/integration/langchain/model_adapter.py +37 -0
- agentrun/integration/langchain/tool_adapter.py +50 -0
- agentrun/integration/langgraph/__init__.py +35 -0
- agentrun/integration/langgraph/adapter.py +20 -0
- agentrun/integration/langgraph/agent_converter.py +1073 -0
- agentrun/integration/langgraph/builtin.py +65 -0
- agentrun/integration/pydantic_ai/__init__.py +12 -0
- agentrun/integration/pydantic_ai/adapter.py +13 -0
- agentrun/integration/pydantic_ai/builtin.py +65 -0
- agentrun/integration/pydantic_ai/model_adapter.py +44 -0
- agentrun/integration/pydantic_ai/tool_adapter.py +19 -0
- agentrun/integration/utils/__init__.py +112 -0
- agentrun/integration/utils/adapter.py +560 -0
- agentrun/integration/utils/canonical.py +164 -0
- agentrun/integration/utils/converter.py +134 -0
- agentrun/integration/utils/model.py +110 -0
- agentrun/integration/utils/tool.py +1759 -0
- agentrun/model/__client_async_template.py +357 -0
- agentrun/model/__init__.py +57 -0
- agentrun/model/__model_proxy_async_template.py +270 -0
- agentrun/model/__model_service_async_template.py +267 -0
- agentrun/model/api/__init__.py +6 -0
- agentrun/model/api/control.py +1173 -0
- agentrun/model/api/data.py +196 -0
- agentrun/model/client.py +674 -0
- agentrun/model/model.py +235 -0
- agentrun/model/model_proxy.py +439 -0
- agentrun/model/model_service.py +438 -0
- agentrun/sandbox/__aio_sandbox_async_template.py +523 -0
- agentrun/sandbox/__browser_sandbox_async_template.py +110 -0
- agentrun/sandbox/__client_async_template.py +491 -0
- agentrun/sandbox/__code_interpreter_sandbox_async_template.py +463 -0
- agentrun/sandbox/__init__.py +69 -0
- agentrun/sandbox/__sandbox_async_template.py +463 -0
- agentrun/sandbox/__template_async_template.py +152 -0
- agentrun/sandbox/aio_sandbox.py +905 -0
- agentrun/sandbox/api/__aio_data_async_template.py +335 -0
- agentrun/sandbox/api/__browser_data_async_template.py +140 -0
- agentrun/sandbox/api/__code_interpreter_data_async_template.py +206 -0
- agentrun/sandbox/api/__init__.py +19 -0
- agentrun/sandbox/api/__sandbox_data_async_template.py +107 -0
- agentrun/sandbox/api/aio_data.py +551 -0
- agentrun/sandbox/api/browser_data.py +172 -0
- agentrun/sandbox/api/code_interpreter_data.py +396 -0
- agentrun/sandbox/api/control.py +1051 -0
- agentrun/sandbox/api/playwright_async.py +492 -0
- agentrun/sandbox/api/playwright_sync.py +492 -0
- agentrun/sandbox/api/sandbox_data.py +154 -0
- agentrun/sandbox/browser_sandbox.py +185 -0
- agentrun/sandbox/client.py +925 -0
- agentrun/sandbox/code_interpreter_sandbox.py +823 -0
- agentrun/sandbox/model.py +397 -0
- agentrun/sandbox/sandbox.py +848 -0
- agentrun/sandbox/template.py +217 -0
- agentrun/server/__init__.py +191 -0
- agentrun/server/agui_normalizer.py +180 -0
- agentrun/server/agui_protocol.py +797 -0
- agentrun/server/invoker.py +309 -0
- agentrun/server/model.py +427 -0
- agentrun/server/openai_protocol.py +535 -0
- agentrun/server/protocol.py +140 -0
- agentrun/server/server.py +208 -0
- agentrun/toolset/__client_async_template.py +62 -0
- agentrun/toolset/__init__.py +51 -0
- agentrun/toolset/__toolset_async_template.py +204 -0
- agentrun/toolset/api/__init__.py +17 -0
- agentrun/toolset/api/control.py +262 -0
- agentrun/toolset/api/mcp.py +100 -0
- agentrun/toolset/api/openapi.py +1251 -0
- agentrun/toolset/client.py +102 -0
- agentrun/toolset/model.py +321 -0
- agentrun/toolset/toolset.py +270 -0
- agentrun/utils/__data_api_async_template.py +720 -0
- agentrun/utils/__init__.py +5 -0
- agentrun/utils/__resource_async_template.py +158 -0
- agentrun/utils/config.py +258 -0
- agentrun/utils/control_api.py +78 -0
- agentrun/utils/data_api.py +1120 -0
- agentrun/utils/exception.py +151 -0
- agentrun/utils/helper.py +108 -0
- agentrun/utils/log.py +77 -0
- agentrun/utils/model.py +168 -0
- agentrun/utils/resource.py +291 -0
- agentrun_inner_test-0.0.46.dist-info/METADATA +263 -0
- agentrun_inner_test-0.0.46.dist-info/RECORD +135 -0
- agentrun_inner_test-0.0.46.dist-info/WHEEL +5 -0
- agentrun_inner_test-0.0.46.dist-info/licenses/LICENSE +201 -0
- agentrun_inner_test-0.0.46.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""LangGraph 内置集成函数 / LangGraph Built-in Integration Functions
|
|
2
|
+
|
|
3
|
+
提供快速创建 LangGraph 兼容模型和工具的便捷函数。
|
|
4
|
+
Provides convenient functions for quickly creating LangGraph-compatible models and tools.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Any, Callable, List, Optional, Union
|
|
8
|
+
|
|
9
|
+
from typing_extensions import Unpack
|
|
10
|
+
|
|
11
|
+
from agentrun.integration.builtin import model as _model
|
|
12
|
+
from agentrun.integration.builtin import ModelArgs
|
|
13
|
+
from agentrun.integration.builtin import sandbox_toolset as _sandbox_toolset
|
|
14
|
+
from agentrun.integration.builtin import toolset as _toolset
|
|
15
|
+
from agentrun.integration.utils.tool import Tool
|
|
16
|
+
from agentrun.model import ModelProxy, ModelService
|
|
17
|
+
from agentrun.sandbox import TemplateType
|
|
18
|
+
from agentrun.toolset import ToolSet
|
|
19
|
+
from agentrun.utils.config import Config
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def model(
|
|
23
|
+
name: Union[str, ModelProxy, ModelService],
|
|
24
|
+
**kwargs: Unpack[ModelArgs],
|
|
25
|
+
):
|
|
26
|
+
"""获取 AgentRun 模型并转换为 LangChain ``BaseChatModel``。 / LangGraph Built-in Integration Functions"""
|
|
27
|
+
|
|
28
|
+
m = _model(input=name, **kwargs) # type: ignore
|
|
29
|
+
return m.to_langgraph()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def toolset(
|
|
33
|
+
name: Union[str, ToolSet],
|
|
34
|
+
*,
|
|
35
|
+
prefix: Optional[str] = None,
|
|
36
|
+
modify_tool_name: Optional[Callable[[Tool], Tool]] = None,
|
|
37
|
+
filter_tools_by_name: Optional[Callable[[str], bool]] = None,
|
|
38
|
+
config: Optional[Config] = None,
|
|
39
|
+
) -> List[Any]:
|
|
40
|
+
"""将内置工具集封装为 LangChain ``StructuredTool`` 列表。 / LangGraph Built-in Integration Functions"""
|
|
41
|
+
|
|
42
|
+
ts = _toolset(input=name, config=config)
|
|
43
|
+
return ts.to_langgraph(
|
|
44
|
+
prefix=prefix,
|
|
45
|
+
modify_tool_name=modify_tool_name,
|
|
46
|
+
filter_tools_by_name=filter_tools_by_name,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def sandbox_toolset(
|
|
51
|
+
template_name: str,
|
|
52
|
+
*,
|
|
53
|
+
template_type: TemplateType = TemplateType.CODE_INTERPRETER,
|
|
54
|
+
config: Optional[Config] = None,
|
|
55
|
+
sandbox_idle_timeout_seconds: int = 600,
|
|
56
|
+
prefix: Optional[str] = None,
|
|
57
|
+
) -> List[Any]:
|
|
58
|
+
"""将沙箱模板封装为 LangChain ``StructuredTool`` 列表。 / LangGraph Built-in Integration Functions"""
|
|
59
|
+
|
|
60
|
+
return _sandbox_toolset(
|
|
61
|
+
template_name=template_name,
|
|
62
|
+
template_type=template_type,
|
|
63
|
+
config=config,
|
|
64
|
+
sandbox_idle_timeout_seconds=sandbox_idle_timeout_seconds,
|
|
65
|
+
).to_langgraph(prefix=prefix)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""PydanticAI 集成模块。 / PydanticAI 集成 Module
|
|
2
|
+
|
|
3
|
+
提供 AgentRun 模型与沙箱工具的 PydanticAI 适配入口。 / 提供 AgentRun 模型with沙箱工具的 PydanticAI 适配入口。
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .builtin import model, sandbox_toolset, toolset
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"model",
|
|
10
|
+
"toolset",
|
|
11
|
+
"sandbox_toolset",
|
|
12
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""PydanticAI 适配器 / PydanticAI Adapters
|
|
2
|
+
|
|
3
|
+
提供 PydanticAI 框架的工具和模型适配器。"""
|
|
4
|
+
|
|
5
|
+
from agentrun.integration.pydantic_ai.model_adapter import (
|
|
6
|
+
PydanticAIModelAdapter,
|
|
7
|
+
)
|
|
8
|
+
from agentrun.integration.pydantic_ai.tool_adapter import PydanticAIToolAdapter
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"PydanticAIToolAdapter",
|
|
12
|
+
"PydanticAIModelAdapter",
|
|
13
|
+
]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""PydanticAI 内置集成函数 / PydanticAI Built-in Integration Functions
|
|
2
|
+
|
|
3
|
+
提供快速创建 PydanticAI 兼容模型和工具的便捷函数。
|
|
4
|
+
Provides convenient functions for quickly creating PydanticAI-compatible models and tools.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Any, Callable, List, Optional, Union
|
|
8
|
+
|
|
9
|
+
from typing_extensions import Unpack
|
|
10
|
+
|
|
11
|
+
from agentrun.integration.builtin import model as _model
|
|
12
|
+
from agentrun.integration.builtin import ModelArgs
|
|
13
|
+
from agentrun.integration.builtin import sandbox_toolset as _sandbox_toolset
|
|
14
|
+
from agentrun.integration.builtin import toolset as _toolset
|
|
15
|
+
from agentrun.integration.utils.tool import Tool
|
|
16
|
+
from agentrun.model import ModelProxy, ModelService
|
|
17
|
+
from agentrun.sandbox import TemplateType
|
|
18
|
+
from agentrun.toolset import ToolSet
|
|
19
|
+
from agentrun.utils.config import Config
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def model(
|
|
23
|
+
name: Union[str, ModelProxy, ModelService],
|
|
24
|
+
**kwargs: Unpack[ModelArgs],
|
|
25
|
+
):
|
|
26
|
+
"""获取 AgentRun 模型并转换为 LangChain ``BaseChatModel``。 / PydanticAI Built-in Integration Functions"""
|
|
27
|
+
|
|
28
|
+
m = _model(input=name, **kwargs) # type: ignore
|
|
29
|
+
return m.to_pydantic_ai()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def toolset(
|
|
33
|
+
name: Union[str, ToolSet],
|
|
34
|
+
*,
|
|
35
|
+
prefix: Optional[str] = None,
|
|
36
|
+
modify_tool_name: Optional[Callable[[Tool], Tool]] = None,
|
|
37
|
+
filter_tools_by_name: Optional[Callable[[str], bool]] = None,
|
|
38
|
+
config: Optional[Config] = None,
|
|
39
|
+
) -> List[Any]:
|
|
40
|
+
"""将内置工具集封装为 LangChain ``StructuredTool`` 列表。 / PydanticAI Built-in Integration Functions"""
|
|
41
|
+
|
|
42
|
+
ts = _toolset(input=name, config=config)
|
|
43
|
+
return ts.to_pydantic_ai(
|
|
44
|
+
prefix=prefix,
|
|
45
|
+
modify_tool_name=modify_tool_name,
|
|
46
|
+
filter_tools_by_name=filter_tools_by_name,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def sandbox_toolset(
|
|
51
|
+
template_name: str,
|
|
52
|
+
*,
|
|
53
|
+
template_type: TemplateType = TemplateType.CODE_INTERPRETER,
|
|
54
|
+
config: Optional[Config] = None,
|
|
55
|
+
sandbox_idle_timeout_seconds: int = 600,
|
|
56
|
+
prefix: Optional[str] = None,
|
|
57
|
+
) -> List[Any]:
|
|
58
|
+
"""将沙箱模板封装为 LangChain ``StructuredTool`` 列表。 / PydanticAI Built-in Integration Functions"""
|
|
59
|
+
|
|
60
|
+
return _sandbox_toolset(
|
|
61
|
+
template_name=template_name,
|
|
62
|
+
template_type=template_type,
|
|
63
|
+
config=config,
|
|
64
|
+
sandbox_idle_timeout_seconds=sandbox_idle_timeout_seconds,
|
|
65
|
+
).to_pydantic_ai(prefix=prefix)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""PydanticAI 模型适配器 / PydanticAI Model Adapter"""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from agentrun.integration.utils.adapter import ModelAdapter
|
|
6
|
+
from agentrun.integration.utils.model import CommonModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PydanticAIModelAdapter(ModelAdapter):
|
|
10
|
+
"""PydanticAI 模型适配器 / PydanticAI Model Adapter
|
|
11
|
+
|
|
12
|
+
PydanticAI 支持 OpenAI 兼容的接口,我们提供一个轻量级包装。"""
|
|
13
|
+
|
|
14
|
+
def wrap_model(self, common_model: CommonModel) -> Any:
|
|
15
|
+
"""将 CommonModel 包装为 PydanticAI 兼容的模型 / PydanticAI Model Adapter"""
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
from pydantic_ai.models.openai import OpenAIChatModel
|
|
19
|
+
from pydantic_ai.providers.openai import OpenAIProvider
|
|
20
|
+
except Exception as e:
|
|
21
|
+
raise ImportError(
|
|
22
|
+
"PydanticAI is not installed. "
|
|
23
|
+
"Install it with: pip install pydantic-ai"
|
|
24
|
+
) from e
|
|
25
|
+
|
|
26
|
+
from httpx import AsyncClient
|
|
27
|
+
|
|
28
|
+
info = common_model.get_model_info()
|
|
29
|
+
|
|
30
|
+
# 注意:不在此处设置 stream_options,因为:
|
|
31
|
+
# 1. run_sync() 使用非流式请求,不需要 stream_options
|
|
32
|
+
# 2. run_stream() 使用流式请求,PydanticAI 会自行处理 usage 信息
|
|
33
|
+
# 3. 在非流式请求中传递 stream_options 不符合 OpenAI API 规范
|
|
34
|
+
return OpenAIChatModel(
|
|
35
|
+
info.model or "",
|
|
36
|
+
provider=OpenAIProvider(
|
|
37
|
+
base_url=info.base_url,
|
|
38
|
+
api_key=info.api_key,
|
|
39
|
+
http_client=AsyncClient(headers=info.headers),
|
|
40
|
+
),
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
__all__ = ["PydanticAIModelAdapter"]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""PydanticAI 工具适配器 / PydanticAI Tool Adapter"""
|
|
2
|
+
|
|
3
|
+
from typing import Any, List
|
|
4
|
+
|
|
5
|
+
from agentrun.integration.utils.adapter import ToolAdapter
|
|
6
|
+
from agentrun.integration.utils.canonical import CanonicalTool
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PydanticAIToolAdapter(ToolAdapter):
|
|
10
|
+
"""PydanticAI 工具适配器 / PydanticAI Tool Adapter
|
|
11
|
+
|
|
12
|
+
PydanticAI 使用函数作为工具,需要附加元数据信息。"""
|
|
13
|
+
|
|
14
|
+
def from_canonical(self, tools: List[CanonicalTool]) -> List[Any]:
|
|
15
|
+
"""将标准工具转换为 PydanticAI 函数格式 / PydanticAI Tool Adapter"""
|
|
16
|
+
return self.function_tools(tools)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
__all__ = ["PydanticAIToolAdapter"]
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""通用集成工具模块 / 通用集成工具 Module
|
|
2
|
+
|
|
3
|
+
提供跨框架的通用工具定义和转换功能。 / 提供跨framework的通用工具定义和转换功能。
|
|
4
|
+
|
|
5
|
+
支持多种工具定义方式:
|
|
6
|
+
1. 使用 @tool 装饰器 - 最简单,推荐
|
|
7
|
+
2. 使用 Pydantic BaseModel - 类型安全
|
|
8
|
+
3. 使用 ToolParameter 列表 - 灵活但繁琐
|
|
9
|
+
4. 从 AgentRun ToolSet 转换 - 直接使用远程工具集
|
|
10
|
+
|
|
11
|
+
支持模型集成:
|
|
12
|
+
1. 使用 model() 函数 - 获取模型并转换为各种框架格式 / 1. 使用 model() 函数 - 获取模型并转换为各种framework格式
|
|
13
|
+
2. 从已有模型对象创建 - from_agentrun_model()
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
>>> # 工具集成示例
|
|
17
|
+
>>> # 方式 1: 使用装饰器从函数创建 Tool
|
|
18
|
+
>>> from agentrun.integration.common import tool
|
|
19
|
+
>>> from typing import Literal
|
|
20
|
+
>>>
|
|
21
|
+
>>> @tool()
|
|
22
|
+
... def calculator(
|
|
23
|
+
... operation: Literal["add", "subtract"],
|
|
24
|
+
... a: float,
|
|
25
|
+
... b: float,
|
|
26
|
+
... ) -> float:
|
|
27
|
+
... '''执行数学运算'''
|
|
28
|
+
... if operation == "add":
|
|
29
|
+
... return a + b
|
|
30
|
+
... return a - b
|
|
31
|
+
>>>
|
|
32
|
+
>>> # 方式 2: 使用 Pydantic 模型
|
|
33
|
+
>>> from agentrun.integration.common import Tool
|
|
34
|
+
>>> from pydantic import BaseModel, Field
|
|
35
|
+
>>>
|
|
36
|
+
>>> class SearchArgs(BaseModel):
|
|
37
|
+
... query: str = Field(description="搜索关键词")
|
|
38
|
+
... limit: int = Field(description="结果数量", ge=1, le=100, default=10)
|
|
39
|
+
>>>
|
|
40
|
+
>>> search_tool = Tool(
|
|
41
|
+
... name="search",
|
|
42
|
+
... description="搜索网络信息",
|
|
43
|
+
... args_schema=SearchArgs,
|
|
44
|
+
... func=lambda query, limit: f"搜索: {query}"
|
|
45
|
+
... )
|
|
46
|
+
>>>
|
|
47
|
+
>>> # 方式 3: 使用 ToolParameter
|
|
48
|
+
>>> from agentrun.integration.common import ToolParameter
|
|
49
|
+
>>>
|
|
50
|
+
>>> weather_tool = Tool(
|
|
51
|
+
... name="weather",
|
|
52
|
+
... description="获取天气信息",
|
|
53
|
+
... parameters=[
|
|
54
|
+
... ToolParameter(
|
|
55
|
+
... name="city",
|
|
56
|
+
... param_type="string",
|
|
57
|
+
... description="城市名称",
|
|
58
|
+
... required=True
|
|
59
|
+
... )
|
|
60
|
+
... ]
|
|
61
|
+
... )
|
|
62
|
+
>>>
|
|
63
|
+
>>> # 方式 4: 从 AgentRun ToolSet 转换
|
|
64
|
+
>>> from agentrun.toolset.client import ToolSetClient
|
|
65
|
+
>>> from agentrun.integration.common import from_agentrun_toolset
|
|
66
|
+
>>>
|
|
67
|
+
>>> client = ToolSetClient()
|
|
68
|
+
>>> remote_toolset = client.get(name="my-toolset")
|
|
69
|
+
>>> common_toolset = from_agentrun_toolset(remote_toolset)
|
|
70
|
+
>>>
|
|
71
|
+
>>> # 导出为各种框架格式 / >>> # 导出为各种framework格式
|
|
72
|
+
>>> openai_tools = common_toolset.to_openai_function()
|
|
73
|
+
>>> langchain_tools = common_toolset.to_langchain()
|
|
74
|
+
>>>
|
|
75
|
+
>>> # 模型集成示例
|
|
76
|
+
>>> # 方式 1: 使用 model() 函数
|
|
77
|
+
>>> from agentrun.integration.common import model
|
|
78
|
+
>>>
|
|
79
|
+
>>> # 获取模型并转换为 LangChain
|
|
80
|
+
>>> llm = model("my-model").to_langchain()
|
|
81
|
+
>>>
|
|
82
|
+
>>> # 转换为 Google ADK
|
|
83
|
+
>>> google_model = model("my-model").to_google_adk()
|
|
84
|
+
>>>
|
|
85
|
+
>>> # 方式 2: 从已有模型对象创建
|
|
86
|
+
>>> from agentrun.model.client import ModelClient
|
|
87
|
+
>>> from agentrun.integration.common import from_agentrun_model
|
|
88
|
+
>>>
|
|
89
|
+
>>> client = ModelClient()
|
|
90
|
+
>>> remote_model = client.get("my-model")
|
|
91
|
+
>>> common_model = from_agentrun_model(remote_model)
|
|
92
|
+
>>> llm = common_model.to_langchain()"""
|
|
93
|
+
|
|
94
|
+
from agentrun.integration.utils.model import CommonModel
|
|
95
|
+
from agentrun.integration.utils.tool import (
|
|
96
|
+
CommonToolSet,
|
|
97
|
+
from_pydantic,
|
|
98
|
+
Tool,
|
|
99
|
+
tool,
|
|
100
|
+
ToolParameter,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
__all__ = [
|
|
104
|
+
# Tool related
|
|
105
|
+
"Tool",
|
|
106
|
+
"ToolParameter",
|
|
107
|
+
"CommonToolSet",
|
|
108
|
+
"tool",
|
|
109
|
+
"from_pydantic",
|
|
110
|
+
# Model related
|
|
111
|
+
"CommonModel",
|
|
112
|
+
]
|