Skip to main content

🚀 快速将任何Agent包装为A2A协议服务 - 三步式API设计,一行代码启动

Project description

EasyA2A - 快速将Agent包装为A2A协议服务

🚀 一行代码,让你的Agent支持A2A协议!

EasyA2A是一个强大而简洁的Python库,让你能够快速将任何LangChain Agent包装成符合A2A协议的服务。采用创新的三步式API设计,大幅简化配置过程,让Agent部署变得前所未有的简单。

✨ 核心特性

  • 🎯 三步式API - 初始化 → 链式配置 → 一键启动
  • 极简使用 - 一行代码即可启动A2A服务
  • 🔧 灵活配置 - 支持技能、能力、提供商等全方位配置
  • 🛠️ 深度集成 - 完美支持LangChain生态
  • 📡 自动生成 - 自动创建符合标准的Agent Card
  • 🌐 即插即用 - 无需复杂配置,开箱即用

🚀 快速开始

安装

pip install easya2a

最简使用(一行代码)

from easya2a import A2AAgentWrapper

# 一行代码启动A2A服务
A2AAgentWrapper.set_up(your_agent, "智能助手", "AI助手服务").run_a2a()

完整示例

from easya2a import A2AAgentWrapper

# 三步式API使用
A2AAgentWrapper.set_up(
    agent=your_langchain_agent,
    name="天气助手", 
    description="智能天气查询服务"
).add_skill(
    "weather_query", "天气查询",
    description="查询全球城市天气信息",
    examples=["北京天气怎么样?", "上海会下雨吗?"]
).add_skill(
    "weather_advice", "穿衣建议", 
    examples=["今天穿什么?", "需要带伞吗?"]
).set_provider(
    "Weather AI Services"
).enable_streaming(
).run_a2a(port=10010)

🎯 三步式API设计

第一步:初始化

wrapper = A2AAgentWrapper.set_up(agent, name, description)

第二步:链式配置(可选)

wrapper.add_skill("chat", "聊天功能") \
       .set_provider("AI Services") \
       .enable_streaming()

第三步:启动服务

wrapper.run_a2a(port=10010, host="0.0.0.0")

📋 API参考

核心方法

方法 说明 示例
set_up(agent, name, desc) 初始化包装器 A2AAgentWrapper.set_up(agent, "助手", "AI服务")
add_skill(id, name, ...) 添加技能 .add_skill("chat", "聊天", examples=["你好"])
set_provider(org, url) 设置提供商 .set_provider("AI Corp", "https://ai.com")
set_version(version) 设置版本 .set_version("2.0.0")
enable_streaming() 启用流式 .enable_streaming()
enable_history() 启用历史 .enable_history()
enable_multimodal() 启用多模态 .enable_multimodal()
run_a2a(port, host) 启动服务 .run_a2a(port=10010)

配置选项

# 技能配置
.add_skill(
    skill_id="weather",           # 技能ID
    name="天气查询",              # 技能名称  
    description="查询天气信息",    # 技能描述
    examples=["今天天气"],        # 使用示例
    tags=["weather", "query"]     # 技能标签
)

# 提供商配置
.set_provider(
    organization="AI Services",   # 组织名称
    url="https://ai.example.com"  # 组织网站
)

# 输入输出模式
.set_input_modes(["text", "json"])
.set_output_modes(["text", "json"])

🌟 使用场景

🤖 聊天机器人

A2AAgentWrapper.set_up(chat_agent, "聊天助手", "智能对话服务") \
               .add_skill("chat", "对话", examples=["你好"]) \
               .run_a2a()

🌤️ 天气服务

A2AAgentWrapper.set_up(weather_agent, "天气助手", "天气查询服务") \
               .add_skill("weather", "天气查询", examples=["北京天气"]) \
               .add_skill("advice", "穿衣建议", examples=["穿什么"]) \
               .run_a2a()

🗺️ 地图服务

A2AAgentWrapper.set_up(map_agent, "地图助手", "地理位置服务") \
               .add_skill("search", "位置搜索", examples=["找餐厅"]) \
               .add_skill("route", "路线规划", examples=["怎么走"]) \
               .run_a2a()

📊 新旧API对比

特性 旧API 新API
代码量 ~50行 ~15行
配置复杂度
学习成本
嵌套层级 4-5层 1层
导入语句 4个类 1个类

旧API(复杂)

config = AgentConfig(
    name="助手",
    skills=[AgentSkillConfig(...)],
    capabilities=AgentCapabilityConfig(...),
    # ... 大量配置
)
wrapper = A2AWrapper(agent, config)
wrapper.run()

新API(简洁)

A2AAgentWrapper.set_up(agent, "助手", "服务") \
               .add_skill("chat", "聊天") \
               .run_a2a()

🔗 相关链接

🤝 贡献

欢迎提交Issue和Pull Request!

📄 许可证

MIT License


让Agent部署变得简单,让A2A协议触手可及! 🚀

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

easya2a-0.2.tar.gz (40.5 kB view details)

Uploaded Source

Built Distribution

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

easya2a-0.2-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file easya2a-0.2.tar.gz.

File metadata

  • Download URL: easya2a-0.2.tar.gz
  • Upload date:
  • Size: 40.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for easya2a-0.2.tar.gz
Algorithm Hash digest
SHA256 0e3c74f4eb4e75445d5779593dc9bb13f6b91d5937b98b3244444e115102ba13
MD5 762d6b1914b71b6715ed38b456bfb139
BLAKE2b-256 2a6b1c5b3ae7bbba12eeb6ac3bdab2da3dabbf757338bb4735c771015aea1b9e

See more details on using hashes here.

File details

Details for the file easya2a-0.2-py3-none-any.whl.

File metadata

  • Download URL: easya2a-0.2-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for easya2a-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c35a392330411c87f83f35d9b52db3d7f4b2a95f545647382cc42c62d35ca320
MD5 c6afe816db7d6643d095697c453fe782
BLAKE2b-256 c8cb90f9d4ede8bb4f5ba5a28a5f65d61231c144d0aaeb98920c4bab30da61c6

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