Skip to main content

Python Agent SDK - 基于 WebSocket 的智能体通信库

Project description

acp-py

Python Agent SDK - 基于 WebSocket 的智能体通信库

安装

pip install acp-py

快速开始

启动 Agent

# 直接启动(使用默认配置)
acp-py

# 指定 Agent 名称
acp-py -n my_agent

# 启用调试模式
acp-py --debug

# 指定目标 Agent(可直接发送消息)
acp-py -t target_agent.aid.pub

交互命令

启动后可以使用以下命令:

命令 说明
/target <aid> 设置目标 Agent
/session 显示当前会话信息
/aid 显示本机 AID
/help 显示帮助
/quit 退出
其他输入 发送消息给目标

CLI 参数

acp-py [选项]

选项:
  -d, --data <path>    数据目录 (默认: ./acp-data)
  -p, --password <pwd> 种子密码
  -n, --name <name>    Agent 名称
  -t, --target <aid>   目标 Agent AID
  --ap <address>       AP 地址 (默认: aid.pub)
  --debug              启用调试模式

自定义 Agent 开发

from agentcp import AgentCP

# 创建 AgentCP 实例
acp = AgentCP("./data", seed_password="your_password", debug=True)

# 创建 Agent
aid = acp.create_aid(ap="aid.pub", agent_name="my_agent")
print(f"Agent AID: {aid.id}")

# 注册消息处理器
async def handle_message(data):
    print(f"收到消息: {data}")

aid.add_message_handler(handle_message)

# 上线
aid.online()

# 发送消息
session_id = aid.create_session("my_session", "测试会话")
aid.invite_member(session_id, "target_agent.aid.pub")
aid.send_message(session_id, ["target_agent.aid.pub"], "Hello!")

# 保持运行
acp.serve_forever()

系统要求

  • Python >= 3.8

平台支持

  • macOS
  • Linux
  • Windows

License

MIT

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

acp_py-1.0.3.tar.gz (141.0 kB view details)

Uploaded Source

Built Distribution

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

acp_py-1.0.3-py3-none-any.whl (172.0 kB view details)

Uploaded Python 3

File details

Details for the file acp_py-1.0.3.tar.gz.

File metadata

  • Download URL: acp_py-1.0.3.tar.gz
  • Upload date:
  • Size: 141.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for acp_py-1.0.3.tar.gz
Algorithm Hash digest
SHA256 8b7df3d8df51abbb2039a06da0d80c3369bef2fb5cf50b27df638a8f82e2db49
MD5 10521f624a6833eec588fd911d342cc2
BLAKE2b-256 41add7e1a85035e7549426403b1ada8bd62a4cc0f1526c7800dc3444fae5e306

See more details on using hashes here.

File details

Details for the file acp_py-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: acp_py-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 172.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for acp_py-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1dd3a8dd90f01dcbf9f3bf648591fafe58441d23074eceed48e1d4214d2e9fe1
MD5 e1225298a7a16d4c40e4de25bb387291
BLAKE2b-256 6af6f8d8ae23d73634cbdbdcdeeadf195889bc8a28f46e329d3243cb3bd9e66d

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