Skip to main content

Agent 训练数据的校验、转换与批处理工具。

Project description

agent-data-tools

项目路径:https://github.com/NairongZheng/agent_data_tools

一个面向 Agent 训练数据的 Python 包,提供三类核心能力:

  • 校验 openai messages 中间格式
  • 转换为 conversations 训练格式
  • 转换为 swift messages 训练格式

这个仓库已经重构为标准的 src 布局,可以直接发布到 PyPI,也可以本地通过 pip install -e . 使用。

项目结构

agent_data_tools/
├── pyproject.toml
├── README.md
├── docs/
│   ├── architecture.md
│   ├── formats.md
│   └── templates.md
├── src/
│   └── agent_data_tools/
│       ├── __init__.py
│       ├── builtin_templates/
│       ├── cli.py
│       ├── converters.py
│       ├── models.py
│       ├── renderers.py
│       ├── schemas.py
│       ├── template_loader.py
│       ├── utils.py
│       ├── validators.py
│       └── py.typed
├── tests/
│   └── test_api.py
└── data_examples/

安装

直接安装:

pip install -e .

安装 pypi 包:

pip install agent-data-tools

快速开始

使用 cli

agent-data-tools validate-openai --data-list datasets/meta.json --log-dir logs
agent-data-tools convert-conversations --data-list datasets/meta.json --output-dir outputs/convs
agent-data-tools convert-swift-messages --data-list datasets/meta.json --output-dir outputs/messages
agent-data-tools convert-conversations --data-list datasets/meta.json --output-dir outputs/convs --template-config ./templates.json
agent-data-tools list-templates

传入 --template-config 时,仅使用配置文件中的模板;未传时默认使用内置模板,其中默认实际生效的是 qwen3.5_35ba3b_think_xml.jinja

使用代码

from agent_data_tools import batch_convert_from_meta

meta_path = batch_convert_from_meta(
    "datasets/meta.json",
    "outputs/conversations",
    target="conversations",
    max_workers=4,
    template_config_path="./templates.json",
)
print(meta_path)

公开 API

常用函数:

  • validate_function_definition
  • validate_openai_messages_record
  • validate_openai_messages_file
  • validate_meta_file
  • convert_record_to_conversations
  • convert_record_to_swift_messages
  • convert_jsonl_file
  • batch_convert_from_meta
  • resolve_template_specs
  • load_builtin_template_specs
  • list_builtin_template_names

配置类:

  • TemplateSpec:描述模板内容、来源与权重
  • RenderConfig:保留给手动渲染扩展场景

结果对象:

  • ValidationResult
  • ConversionStats

设计原则

  • openai messages 作为统一中间格式
  • 将“校验”“模板加载”“转换”“批处理”拆分为独立模块
  • 默认内置模板开箱即用,同时允许用户传入模板配置 JSON 覆盖默认模板选择
  • conversations 与 swift messages 共用同一套模板渲染入口

文档

验证

PYTHONPATH=src python -m unittest tests/test_api.py
PYTHONPATH=src python -m agent_data_tools.cli list-templates
PYTHONPATH=src python -m agent_data_tools.cli --help

发布

构建分发包:

python -m pip install build
python -m build

上传前检查:

python -m pip install twine
python -m twine check dist/*

完整发布说明见 docs/release.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_data_tools-0.1.2.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_data_tools-0.1.2-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file agent_data_tools-0.1.2.tar.gz.

File metadata

  • Download URL: agent_data_tools-0.1.2.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for agent_data_tools-0.1.2.tar.gz
Algorithm Hash digest
SHA256 390b89bd5e3c7a268924bb9f1f8eb25a4092b8721577551f13e352a2701c9e1b
MD5 3ed2ba6ab31ec0c05b42788ba93ae025
BLAKE2b-256 6e975d48bd92fc1ebf2f42d32f961c6ccb97ae90ec23563aeab24f0233b9736e

See more details on using hashes here.

File details

Details for the file agent_data_tools-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_data_tools-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1159cf56001d8364d66ef0984f53b313d91811a80fa32b4271d87bd53933dd1e
MD5 2706816e5826c316d1927a7e11351501
BLAKE2b-256 fc7d8ed0372e2385922e5ce9631223ecbced3362d0bdf66296e3c8a09eb97616

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page