refactor: rename tool modules and clean imports
This commit is contained in:
@@ -4,32 +4,31 @@ 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)
|
- [Quick Start](#quick-start)
|
||||||
- [Quick Start](#quick-start)
|
- [System Requirements](#system-requirements)
|
||||||
- [System Requirements](#system-requirements)
|
- [Installation](#installation)
|
||||||
- [Installation](#installation)
|
- [Configuration](#configuration)
|
||||||
- [Configuration](#configuration)
|
- [Usage](#usage)
|
||||||
- [Usage](#usage)
|
- [Agent Introduction](#agent-introduction)
|
||||||
- [Agent Introduction](#agent-introduction)
|
- [Data Processing Agent](#data-processing-agent)
|
||||||
- [Data Processing Agent](#data-processing-agent)
|
- [Code Development Agent (DJ Dev Agent)](#code-development-agent-dj-dev-agent)
|
||||||
- [Code Development Agent (DJ Dev Agent)](#code-development-agent-dj-dev-agent)
|
- [Advanced Features](#advanced-features)
|
||||||
- [Advanced Features](#advanced-features)
|
- [Operator Retrieval](#operator-retrieval)
|
||||||
- [Operator Retrieval](#operator-retrieval)
|
- [Retrieval Modes](#retrieval-modes)
|
||||||
- [Retrieval Modes](#retrieval-modes)
|
- [Usage](#usage-1)
|
||||||
- [Usage](#usage-1)
|
- [MCP Agent](#mcp-agent)
|
||||||
- [MCP Agent](#mcp-agent)
|
- [MCP Server Types](#mcp-server-types)
|
||||||
- [MCP Server Types](#mcp-server-types)
|
- [Configuration](#configuration-1)
|
||||||
- [Configuration](#configuration-1)
|
- [Usage Methods](#usage-methods)
|
||||||
- [Usage Methods](#usage-methods)
|
- [Feature Preview](#feature-preview)
|
||||||
- [Feature Preview](#feature-preview)
|
- [Data-Juicer Q\&A Agent (Demo Available)](#data-juicer-qa-agent-demo-available)
|
||||||
- [Data-Juicer Q\&A Agent (Demo Available)](#data-juicer-qa-agent-demo-available)
|
- [Data Analysis and Visualization Agent (In Development)](#data-analysis-and-visualization-agent-in-development)
|
||||||
- [Data Analysis and Visualization Agent (In Development)](#data-analysis-and-visualization-agent-in-development)
|
- [Troubleshooting](#troubleshooting)
|
||||||
- [Troubleshooting](#troubleshooting)
|
- [Common Issues](#common-issues)
|
||||||
- [Common Issues](#common-issues)
|
- [Optimization Recommendations](#optimization-recommendations)
|
||||||
- [Optimization Recommendations](#optimization-recommendations)
|
|
||||||
|
|
||||||
## What Does This Agent Do?
|
## What Does This Agent Do?
|
||||||
|
|
||||||
@@ -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,31 +4,30 @@
|
|||||||
|
|
||||||
## 📋 目录
|
## 📋 目录
|
||||||
|
|
||||||
- [DataJuicer 智能体](#datajuicer-智能体)
|
- [📋 目录](#-目录)
|
||||||
- [📋 目录](#-目录)
|
- [这个智能体做了什么?](#这个智能体做了什么)
|
||||||
- [这个智能体做了什么?](#这个智能体做了什么)
|
- [架构](#架构)
|
||||||
- [架构](#架构)
|
- [快速开始](#快速开始)
|
||||||
- [快速开始](#快速开始)
|
- [系统要求](#系统要求)
|
||||||
- [系统要求](#系统要求)
|
- [安装](#安装)
|
||||||
- [安装](#安装)
|
- [配置](#配置)
|
||||||
- [配置](#配置)
|
- [使用](#使用)
|
||||||
- [使用](#使用)
|
- [智能体介绍](#智能体介绍)
|
||||||
- [智能体介绍](#智能体介绍)
|
- [数据处理智能体](#数据处理智能体)
|
||||||
- [数据处理智能体](#数据处理智能体)
|
- [代码开发智能体](#代码开发智能体)
|
||||||
- [代码开发智能体](#代码开发智能体)
|
- [高级功能](#高级功能)
|
||||||
- [高级功能](#高级功能)
|
- [算子检索](#算子检索)
|
||||||
- [算子检索](#算子检索)
|
- [检索模式](#检索模式)
|
||||||
- [检索模式](#检索模式)
|
- [使用](#使用-1)
|
||||||
- [使用](#使用-1)
|
- [MCP 智能体](#mcp-智能体)
|
||||||
- [MCP 智能体](#mcp-智能体)
|
- [MCP 服务器类型](#mcp-服务器类型)
|
||||||
- [MCP 服务器类型](#mcp-服务器类型)
|
- [配置](#配置-1)
|
||||||
- [配置](#配置-1)
|
- [使用方法](#使用方法)
|
||||||
- [使用方法](#使用方法)
|
- [功能预览](#功能预览)
|
||||||
- [功能预览](#功能预览)
|
- [Data-Juicer 问答智能体 (演示可用)](#data-juicer-问答智能体-演示可用)
|
||||||
- [Data-Juicer 问答智能体 (演示可用)](#data-juicer-问答智能体-演示可用)
|
- [数据分析与可视化智能体 (开发中)](#数据分析与可视化智能体-开发中)
|
||||||
- [数据分析与可视化智能体 (开发中)](#数据分析与可视化智能体-开发中)
|
- [常见问题](#常见问题)
|
||||||
- [常见问题](#常见问题)
|
- [优化建议](#优化建议)
|
||||||
- [优化建议](#优化建议)
|
|
||||||
|
|
||||||
## 这个智能体做了什么?
|
## 这个智能体做了什么?
|
||||||
|
|
||||||
@@ -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