agentrun-inner-test 0.0.62__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.
Potentially problematic release.
This version of agentrun-inner-test might be problematic. Click here for more details.
- agentrun/__init__.py +358 -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 +13 -0
- agentrun/integration/agentscope/adapter.py +17 -0
- agentrun/integration/agentscope/builtin.py +88 -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 +18 -0
- agentrun/integration/builtin/knowledgebase.py +137 -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 +13 -0
- agentrun/integration/crewai/adapter.py +9 -0
- agentrun/integration/crewai/builtin.py +88 -0
- agentrun/integration/crewai/model_adapter.py +31 -0
- agentrun/integration/crewai/tool_adapter.py +26 -0
- agentrun/integration/google_adk/__init__.py +13 -0
- agentrun/integration/google_adk/adapter.py +15 -0
- agentrun/integration/google_adk/builtin.py +88 -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 +31 -0
- agentrun/integration/langchain/adapter.py +15 -0
- agentrun/integration/langchain/builtin.py +94 -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 +36 -0
- agentrun/integration/langgraph/adapter.py +20 -0
- agentrun/integration/langgraph/agent_converter.py +1073 -0
- agentrun/integration/langgraph/builtin.py +88 -0
- agentrun/integration/pydantic_ai/__init__.py +13 -0
- agentrun/integration/pydantic_ai/adapter.py +13 -0
- agentrun/integration/pydantic_ai/builtin.py +88 -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/knowledgebase/__client_async_template.py +173 -0
- agentrun/knowledgebase/__init__.py +53 -0
- agentrun/knowledgebase/__knowledgebase_async_template.py +438 -0
- agentrun/knowledgebase/api/__data_async_template.py +414 -0
- agentrun/knowledgebase/api/__init__.py +19 -0
- agentrun/knowledgebase/api/control.py +606 -0
- agentrun/knowledgebase/api/data.py +624 -0
- agentrun/knowledgebase/client.py +311 -0
- agentrun/knowledgebase/knowledgebase.py +748 -0
- agentrun/knowledgebase/model.py +270 -0
- agentrun/memory_collection/__client_async_template.py +178 -0
- agentrun/memory_collection/__init__.py +37 -0
- agentrun/memory_collection/__memory_collection_async_template.py +457 -0
- agentrun/memory_collection/api/__init__.py +5 -0
- agentrun/memory_collection/api/control.py +610 -0
- agentrun/memory_collection/client.py +323 -0
- agentrun/memory_collection/memory_collection.py +844 -0
- agentrun/memory_collection/model.py +162 -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 +912 -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 +384 -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 +271 -0
- agentrun/utils/__data_api_async_template.py +721 -0
- agentrun/utils/__init__.py +5 -0
- agentrun/utils/__resource_async_template.py +158 -0
- agentrun/utils/config.py +270 -0
- agentrun/utils/control_api.py +105 -0
- agentrun/utils/data_api.py +1121 -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.62.dist-info/METADATA +265 -0
- agentrun_inner_test-0.0.62.dist-info/RECORD +154 -0
- agentrun_inner_test-0.0.62.dist-info/WHEEL +5 -0
- agentrun_inner_test-0.0.62.dist-info/licenses/LICENSE +201 -0
- agentrun_inner_test-0.0.62.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Builtin Integration 模块 / Builtin Integration Module
|
|
2
|
+
|
|
3
|
+
此模块提供内置的集成函数,用于快速创建模型和工具。
|
|
4
|
+
This module provides built-in integration functions for quickly creating models and tools.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .knowledgebase import knowledgebase_toolset
|
|
8
|
+
from .model import model, ModelArgs
|
|
9
|
+
from .sandbox import sandbox_toolset
|
|
10
|
+
from .toolset import toolset
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"model",
|
|
14
|
+
"ModelArgs",
|
|
15
|
+
"toolset",
|
|
16
|
+
"sandbox_toolset",
|
|
17
|
+
"knowledgebase_toolset",
|
|
18
|
+
]
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""知识库工具集 / KnowledgeBase ToolSet
|
|
2
|
+
|
|
3
|
+
提供知识库检索功能的工具集,支持多知识库联合检索。
|
|
4
|
+
Provides toolset for knowledge base retrieval, supporting multi-knowledge-base search.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
from agentrun.integration.utils.tool import CommonToolSet, tool
|
|
12
|
+
from agentrun.knowledgebase import KnowledgeBase
|
|
13
|
+
from agentrun.utils.config import Config
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class KnowledgeBaseToolSet(CommonToolSet):
|
|
17
|
+
"""知识库工具集 / KnowledgeBase ToolSet
|
|
18
|
+
|
|
19
|
+
提供知识库检索功能,支持对多个知识库进行联合检索。
|
|
20
|
+
Provides knowledge base retrieval capabilities, supporting joint retrieval
|
|
21
|
+
across multiple knowledge bases.
|
|
22
|
+
|
|
23
|
+
使用指南 / Usage Guide:
|
|
24
|
+
============================================================
|
|
25
|
+
|
|
26
|
+
## 基本用法 / Basic Usage
|
|
27
|
+
|
|
28
|
+
1. **创建工具集 / Create ToolSet**:
|
|
29
|
+
- 使用 `knowledgebase_toolset` 函数创建工具集实例
|
|
30
|
+
- Use `knowledgebase_toolset` function to create a toolset instance
|
|
31
|
+
- 指定要检索的知识库名称列表
|
|
32
|
+
- Specify the list of knowledge base names to search
|
|
33
|
+
|
|
34
|
+
2. **执行检索 / Execute Search**:
|
|
35
|
+
- 调用 `search_document` 工具进行检索
|
|
36
|
+
- Call `search_document` tool to perform retrieval
|
|
37
|
+
- 返回所有指定知识库的检索结果
|
|
38
|
+
- Returns retrieval results from all specified knowledge bases
|
|
39
|
+
|
|
40
|
+
## 示例 / Examples
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from agentrun.integration.langchain import knowledgebase_toolset
|
|
44
|
+
|
|
45
|
+
# 创建工具集 / Create toolset
|
|
46
|
+
tools = knowledgebase_toolset(
|
|
47
|
+
knowledge_base_names=["kb-product-docs", "kb-faq"],
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# 在 Agent 中使用 / Use in Agent
|
|
51
|
+
agent = create_react_agent(llm, tools)
|
|
52
|
+
```
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
def __init__(
|
|
56
|
+
self,
|
|
57
|
+
knowledge_base_names: List[str],
|
|
58
|
+
config: Optional[Config] = None,
|
|
59
|
+
) -> None:
|
|
60
|
+
"""初始化知识库工具集 / Initialize KnowledgeBase ToolSet
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
knowledge_base_names: 知识库名称列表 / List of knowledge base names
|
|
64
|
+
config: 配置 / Configuration
|
|
65
|
+
"""
|
|
66
|
+
super().__init__()
|
|
67
|
+
|
|
68
|
+
self.knowledge_base_names = knowledge_base_names
|
|
69
|
+
self.config = config
|
|
70
|
+
|
|
71
|
+
@tool(
|
|
72
|
+
name="search_document",
|
|
73
|
+
description=(
|
|
74
|
+
"Search and retrieve relevant documents from configured knowledge"
|
|
75
|
+
" bases. Use this tool when you need to find information from the"
|
|
76
|
+
" knowledge base to answer user questions. Returns relevant"
|
|
77
|
+
" document chunks with their content and metadata. The search is"
|
|
78
|
+
" performed across all configured knowledge bases and results are"
|
|
79
|
+
" grouped by knowledge base name."
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
def search_document(self, query: str) -> Dict[str, Any]:
|
|
83
|
+
"""检索文档 / Search documents
|
|
84
|
+
|
|
85
|
+
根据查询文本从配置的知识库中检索相关文档。
|
|
86
|
+
Retrieves relevant documents from configured knowledge bases based on query text.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
query: 查询文本 / Query text
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Dict[str, Any]: 检索结果,包含各知识库的检索结果 /
|
|
93
|
+
Retrieval results containing results from each knowledge base
|
|
94
|
+
"""
|
|
95
|
+
return KnowledgeBase.multi_retrieve(
|
|
96
|
+
query=query,
|
|
97
|
+
knowledge_base_names=self.knowledge_base_names,
|
|
98
|
+
config=self.config,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def knowledgebase_toolset(
|
|
103
|
+
knowledge_base_names: List[str],
|
|
104
|
+
*,
|
|
105
|
+
config: Optional[Config] = None,
|
|
106
|
+
) -> KnowledgeBaseToolSet:
|
|
107
|
+
"""创建知识库工具集 / Create KnowledgeBase ToolSet
|
|
108
|
+
|
|
109
|
+
将知识库检索功能封装为通用工具集,可转换为各框架支持的格式。
|
|
110
|
+
Wraps knowledge base retrieval functionality into a common toolset that can be
|
|
111
|
+
converted to formats supported by various frameworks.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
knowledge_base_names: 知识库名称列表 / List of knowledge base names
|
|
115
|
+
config: 配置 / Configuration
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
KnowledgeBaseToolSet: 知识库工具集实例 / KnowledgeBase toolset instance
|
|
119
|
+
|
|
120
|
+
Example:
|
|
121
|
+
>>> from agentrun.integration.builtin import knowledgebase_toolset
|
|
122
|
+
>>>
|
|
123
|
+
>>> # 创建工具集 / Create toolset
|
|
124
|
+
>>> kb_tools = knowledgebase_toolset(
|
|
125
|
+
... knowledge_base_names=["kb-docs", "kb-faq"],
|
|
126
|
+
... )
|
|
127
|
+
>>>
|
|
128
|
+
>>> # 转换为 LangChain 格式 / Convert to LangChain format
|
|
129
|
+
>>> langchain_tools = kb_tools.to_langchain()
|
|
130
|
+
>>>
|
|
131
|
+
>>> # 转换为 Google ADK 格式 / Convert to Google ADK format
|
|
132
|
+
>>> adk_tools = kb_tools.to_google_adk()
|
|
133
|
+
"""
|
|
134
|
+
return KnowledgeBaseToolSet(
|
|
135
|
+
knowledge_base_names=knowledge_base_names,
|
|
136
|
+
config=config,
|
|
137
|
+
)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""内置模型集成函数 / Built-in Model Integration Functions
|
|
2
|
+
|
|
3
|
+
提供快速创建通用模型对象的便捷函数。
|
|
4
|
+
Provides convenient functions for quickly creating common model objects.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Optional, overload, TypedDict, Union
|
|
8
|
+
|
|
9
|
+
from typing_extensions import NotRequired, Unpack
|
|
10
|
+
|
|
11
|
+
from agentrun.integration.utils.model import CommonModel
|
|
12
|
+
from agentrun.model import ModelService
|
|
13
|
+
from agentrun.model.model import BackendType
|
|
14
|
+
from agentrun.model.model_proxy import ModelProxy
|
|
15
|
+
from agentrun.utils.config import Config
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ModelArgs(TypedDict):
|
|
19
|
+
model: NotRequired[Optional[str]]
|
|
20
|
+
backend_type: NotRequired[Optional[BackendType]]
|
|
21
|
+
config: NotRequired[Optional[Config]]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@overload
|
|
25
|
+
def model(input: ModelService, **kwargs: Unpack[ModelArgs]) -> CommonModel:
|
|
26
|
+
...
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@overload
|
|
30
|
+
def model(input: ModelProxy, **kwargs: Unpack[ModelArgs]) -> CommonModel:
|
|
31
|
+
...
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@overload
|
|
35
|
+
def model(input: str, **kwargs: Unpack[ModelArgs]) -> CommonModel:
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def model(
|
|
40
|
+
input: Union[str, ModelProxy, ModelService], **kwargs: Unpack[ModelArgs]
|
|
41
|
+
) -> CommonModel:
|
|
42
|
+
"""获取 AgentRun 模型并封装为通用 Model 对象 / Get AgentRun model and wrap as CommonModel
|
|
43
|
+
|
|
44
|
+
等价于 ModelClient.get(),但返回通用 Model 对象。
|
|
45
|
+
Equivalent to ModelClient.get(), but returns a CommonModel object.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
input: AgentRun 模型名称、ModelProxy 或 ModelService 实例 / Model name, ModelProxy or ModelService instance
|
|
49
|
+
model: 要请求的模型名称(默认请求数组的第一个模型或模型治理的自动负载均衡模型) / Model name to request (defaults to the first model in the array or the auto-load balancing model of model governance)
|
|
50
|
+
backend_type: 后端类型(PROXY 或 SERVICE) / Backend type (PROXY or SERVICE)
|
|
51
|
+
config: 配置对象 / Configuration object
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
CommonModel: 通用模型实例 / CommonModel instance
|
|
55
|
+
|
|
56
|
+
Examples:
|
|
57
|
+
>>> # 从模型名称创建 / Create from model name
|
|
58
|
+
>>> m = model("qwen-max")
|
|
59
|
+
>>>
|
|
60
|
+
>>> # 从 ModelProxy 创建 / Create from ModelProxy
|
|
61
|
+
>>> proxy = ModelProxy.get_by_name("my-proxy")
|
|
62
|
+
>>> m = model(proxy)
|
|
63
|
+
>>>
|
|
64
|
+
>>> # 从 ModelService 创建 / Create from ModelService
|
|
65
|
+
>>> service = ModelService.get_by_name("my-service")
|
|
66
|
+
>>> m = model(service)
|
|
67
|
+
"""
|
|
68
|
+
config = kwargs.get("config")
|
|
69
|
+
backend_type = kwargs.get("backend_type")
|
|
70
|
+
model = kwargs.get("model")
|
|
71
|
+
|
|
72
|
+
if isinstance(input, str):
|
|
73
|
+
from agentrun.model.client import ModelClient
|
|
74
|
+
|
|
75
|
+
client = ModelClient(config=config)
|
|
76
|
+
input = client.get(name=input, backend_type=backend_type, config=config)
|
|
77
|
+
|
|
78
|
+
if isinstance(input, ModelProxy):
|
|
79
|
+
return CommonModel(
|
|
80
|
+
model_obj=input,
|
|
81
|
+
backend_type=BackendType.PROXY,
|
|
82
|
+
specific_model=model,
|
|
83
|
+
config=config,
|
|
84
|
+
)
|
|
85
|
+
elif isinstance(input, ModelService):
|
|
86
|
+
return CommonModel(
|
|
87
|
+
model_obj=input,
|
|
88
|
+
backend_type=BackendType.SERVICE,
|
|
89
|
+
specific_model=model,
|
|
90
|
+
config=config,
|
|
91
|
+
)
|
|
92
|
+
else:
|
|
93
|
+
raise TypeError("input must be str, ModelProxy or ModelService")
|