refactor: rename tool modules and clean imports
This commit is contained in:
@@ -4,7 +4,6 @@ A multi-agent data processing system built on [AgentScope](https://github.com/mo
|
|||||||
|
|
||||||
## 📋 Table of Contents
|
## 📋 Table of Contents
|
||||||
|
|
||||||
- [DataJuicer Agent](#datajuicer-agent)
|
|
||||||
- [📋 Table of Contents](#-table-of-contents)
|
- [📋 Table of Contents](#-table-of-contents)
|
||||||
- [What Does This Agent Do?](#what-does-this-agent-do)
|
- [What Does This Agent Do?](#what-does-this-agent-do)
|
||||||
- [Architecture](#architecture)
|
- [Architecture](#architecture)
|
||||||
@@ -62,7 +61,7 @@ Router Agent ──┐
|
|||||||
|
|
||||||
### System Requirements
|
### System Requirements
|
||||||
|
|
||||||
- Python 3.8+
|
- Python 3.10+
|
||||||
- Valid DashScope API key
|
- Valid DashScope API key
|
||||||
- Optional: Data-Juicer source code (for custom operator development)
|
- Optional: Data-Juicer source code (for custom operator development)
|
||||||
|
|
||||||
@@ -103,7 +102,7 @@ Choose the running mode using the `-u` or `--use_studio` parameter:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Use AgentScope Studio (provides interactive interface)
|
# Use AgentScope Studio (provides interactive interface)
|
||||||
python main.py --use_studio true
|
python main.py --use_studio True
|
||||||
|
|
||||||
# Or use command-line mode (default)
|
# Or use command-line mode (default)
|
||||||
python main.py
|
python main.py
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
## 📋 目录
|
## 📋 目录
|
||||||
|
|
||||||
- [DataJuicer 智能体](#datajuicer-智能体)
|
|
||||||
- [📋 目录](#-目录)
|
- [📋 目录](#-目录)
|
||||||
- [这个智能体做了什么?](#这个智能体做了什么)
|
- [这个智能体做了什么?](#这个智能体做了什么)
|
||||||
- [架构](#架构)
|
- [架构](#架构)
|
||||||
@@ -61,7 +60,7 @@ Data-Juicer (DJ) 是一个一站式系统,面向大模型的文本及多模态
|
|||||||
|
|
||||||
### 系统要求
|
### 系统要求
|
||||||
|
|
||||||
- Python 3.8+
|
- Python 3.10+
|
||||||
- 有效的 DashScope API 密钥
|
- 有效的 DashScope API 密钥
|
||||||
- 可选:Data-Juicer 源码(用于自定义算子开发)
|
- 可选:Data-Juicer 源码(用于自定义算子开发)
|
||||||
|
|
||||||
@@ -102,7 +101,7 @@ export DATA_JUICER_PATH="your-data-juicer-path"
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 使用 AgentScope Studio(提供交互式界面)
|
# 使用 AgentScope Studio(提供交互式界面)
|
||||||
python main.py --use_studio true
|
python main.py --use_studio True
|
||||||
|
|
||||||
# 或使用命令行模式(默认)
|
# 或使用命令行模式(默认)
|
||||||
python main.py
|
python main.py
|
||||||
|
|||||||
0
data_juicer_agent/__init__.py
Normal file
0
data_juicer_agent/__init__.py
Normal file
@@ -8,9 +8,9 @@ from agentscope.formatter import DashScopeChatFormatter
|
|||||||
from agentscope.memory import InMemoryMemory
|
from agentscope.memory import InMemoryMemory
|
||||||
from agentscope.agent import UserAgent
|
from agentscope.agent import UserAgent
|
||||||
|
|
||||||
from .agent_factory import create_agent
|
from agent_factory import create_agent
|
||||||
from .prompts import DJ_SYS_PROMPT, DJ_DEV_SYS_PROMPT, ROUTER_SYS_PROMPT, MCP_SYS_PROMPT
|
from prompts import DJ_SYS_PROMPT, DJ_DEV_SYS_PROMPT, ROUTER_SYS_PROMPT, MCP_SYS_PROMPT
|
||||||
from .tools import (
|
from tools import (
|
||||||
dj_toolkit,
|
dj_toolkit,
|
||||||
dj_dev_toolkit,
|
dj_dev_toolkit,
|
||||||
mcp_tools,
|
mcp_tools,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ Tools package for data-agent.
|
|||||||
This module provides a unified entry point for all agent tools,
|
This module provides a unified entry point for all agent tools,
|
||||||
organized by agent type for easy access and management.
|
organized by agent type for easy access and management.
|
||||||
"""
|
"""
|
||||||
import asyncio
|
|
||||||
from typing import List
|
from typing import List
|
||||||
from agentscope.agent import AgentBase
|
from agentscope.agent import AgentBase
|
||||||
from agentscope.tool import (
|
from agentscope.tool import (
|
||||||
@@ -14,11 +13,11 @@ from agentscope.tool import (
|
|||||||
)
|
)
|
||||||
from agentscope.tool import Toolkit
|
from agentscope.tool import Toolkit
|
||||||
|
|
||||||
from .dj_tools import execute_safe_command
|
from .dj_helpers import execute_safe_command
|
||||||
from .router_tools import agent_to_tool
|
from .router_helpers import agent_to_tool
|
||||||
from .dj_tools import query_dj_operators
|
from .dj_helpers import query_dj_operators
|
||||||
from .dj_dev_tools import get_basic_files, get_operator_example, configure_data_juicer_path
|
from .dj_dev_helpers import get_basic_files, get_operator_example, configure_data_juicer_path
|
||||||
from .mcp_tools import get_mcp_toolkit
|
from .mcp_helpers import get_mcp_toolkit
|
||||||
|
|
||||||
def create_toolkit(tools: List[str]):
|
def create_toolkit(tools: List[str]):
|
||||||
# Create toolkit and register tools
|
# Create toolkit and register tools
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ and example code for different operator types.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
|
||||||
from agentscope.message import TextBlock
|
from agentscope.message import TextBlock
|
||||||
from agentscope.tool import ToolResponse
|
from agentscope.tool import ToolResponse
|
||||||
|
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
root_path = Path(__file__).parent.parent
|
||||||
|
sys.path.insert(0, str(root_path))
|
||||||
|
sys.path.insert(0, str(Path(root_path)/"data_juicer_agent"))
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
from agentscope.agent import ReActAgent
|
from agentscope.agent import ReActAgent
|
||||||
@@ -22,6 +30,7 @@ from data_juicer_agent.tools import (
|
|||||||
dj_tools,
|
dj_tools,
|
||||||
dj_dev_tools,
|
dj_dev_tools,
|
||||||
mcp_tools,
|
mcp_tools,
|
||||||
|
get_mcp_toolkit,
|
||||||
execute_safe_command,
|
execute_safe_command,
|
||||||
query_dj_operators,
|
query_dj_operators,
|
||||||
get_basic_files,
|
get_basic_files,
|
||||||
@@ -29,6 +38,7 @@ from data_juicer_agent.tools import (
|
|||||||
configure_data_juicer_path,
|
configure_data_juicer_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestDataJuicerAgent:
|
class TestDataJuicerAgent:
|
||||||
"""Test suite for the data_juicer_agent functionality"""
|
"""Test suite for the data_juicer_agent functionality"""
|
||||||
|
|
||||||
@@ -138,6 +148,13 @@ class TestDataJuicerAgent:
|
|||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_mcp_tools_list(self, mock_mcp_client):
|
async def test_mcp_tools_list(self, mock_mcp_client):
|
||||||
"""Test MCP tools list contains expected tools and MCP client binding"""
|
"""Test MCP tools list contains expected tools and MCP client binding"""
|
||||||
|
with patch(
|
||||||
|
"agentscope.mcp.HttpStatefulClient",
|
||||||
|
return_value=mock_mcp_client,
|
||||||
|
) as mock_client_cls:
|
||||||
|
await get_mcp_toolkit()
|
||||||
|
assert mock_client_cls.assert_called_once
|
||||||
|
|
||||||
expected_tools = [view_text_file, write_text_file]
|
expected_tools = [view_text_file, write_text_file]
|
||||||
assert len(mcp_tools) == len(expected_tools)
|
assert len(mcp_tools) == len(expected_tools)
|
||||||
for tool in expected_tools:
|
for tool in expected_tools:
|
||||||
@@ -179,7 +196,7 @@ class TestDataJuicerAgent:
|
|||||||
mock_mcp_clients = [mock_mcp_client]
|
mock_mcp_clients = [mock_mcp_client]
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"data_juicer_agent.tools.mcp_tools._create_clients",
|
"data_juicer_agent.tools.mcp_helpers._create_clients",
|
||||||
return_value=mock_mcp_clients,
|
return_value=mock_mcp_clients,
|
||||||
):
|
):
|
||||||
with patch(
|
with patch(
|
||||||
@@ -216,5 +233,6 @@ class TestDataJuicerAgent:
|
|||||||
)
|
)
|
||||||
assert mcp_agent_created, "MCP agent should be created"
|
assert mcp_agent_created, "MCP agent should be created"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pytest.main(["-v", __file__])
|
pytest.main(["-v", __file__])
|
||||||
Reference in New Issue
Block a user