Current collected state Current
Observed since 20 Oct, 16:23 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
将 CrewAI Agent 一行命令转为 A2A 服务 — 开源替代 CrewAI AMP 的本地开发方案
将 CrewAI Agent 一行命令转为 A2A 服务 — 开源替代 CrewAI AMP 的本地开发方案。
基于 AutoA2A (NapthaAI) 和 Google A2A Protocol。
pip install a2a_auto_wrapper
同时需要安装 CrewAI:
pip install crewai
# crewai_a2a_server.py
from crewai import Agent, LLM
from crewai.a2a import A2AServerConfig
from a2a_auto_wrapper import serve_crewai_agent
analyst = Agent(
role="数据分析师",
goal="对数据进行深度分析并生成结构化报告",
backstory="你是资深数据分析师,擅长数据洞察和趋势预测。",
llm=LLM(model="deepseek-chat", base_url="https://api.deepseek.com/v1", api_key="..."),
a2a=A2AServerConfig(url="http://localhost:2025"),
)
if __name__ == "__main__":
serve_crewai_agent(analyst, port=2025)
python crewai_a2a_server.py
# ✅ 服务运行在 http://localhost:2025
import asyncio
from a2a_auto_wrapper import A2AClient
async def main():
client = A2AClient("http://localhost:2025/")
result = await client.send_message("分析销售数据:1月100万 2月120万 3月90万")
print(result)
asyncio.run(main())
# deepagent_a2a.py
from a2a_auto_wrapper import A2AClient
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool
from deepagents import create_deep_agent
crewai_client = A2AClient(base_url="http://localhost:2025/")
@tool
async def call_crewai_analyst(query: str) -> str:
"""需要数据分析时调用 CrewAI 分析师。"""
return await crewai_client.send_message(query)
agent = create_deep_agent(
model=ChatOpenAI(model="deepseek-chat", ...),
tools=[call_crewai_analyst],
)
graph = agent # langgraph dev 加载入口
serve_crewai_agent(agent, port=2025)启动 CrewAI Agent 为 A2A HTTP 服务。
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
agent | crewai.Agent | 必填 | 已配置 A2AServerConfig 的 CrewAI Agent |
port | int | 2025 | 监听端口 |
A2AClientA2A 客户端,调用远程 A2A 服务。
client = A2AClient(base_url: str, timeout: int = 120)
result = await client.send_message(text: str) -> str
| 方法 | 参数 | 返回值 | 说明 |
|---|---|---|---|
__init__ | base_url, timeout=120 | — | 构造客户端 |
send_message | text | str | 发送消息,返回结果文本 |
用户 → langgraph_sdk → DeepAgents (:2024) → A2A → CrewAI (:2025)
crewai (安装本包后需单独安装)httpx, starlette, uvicorn, pydanticMIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.0 | 18 Jul 2026 | 9 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 16:23 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:7fa3885e1914e3c3c902df928f438c36046fdfee9b46d05bbd10c11208f033c7