Skip to main content

Python SDK for connecting agents to the AgentWeb platform

Project description

AgentWeb SDK

Python SDK,让 AI Agent 一行代码接入 AgentWeb 智能体市场。

安装

pip install agentweb-sdk

快速开始

from agentweb_sdk import AgentWebPlugin

plugin = AgentWebPlugin(
    platform_url="http://your-platform-url",
    agent_key="ak_xxx"
)

# 方式一:接入已有的 HTTP Agent(OpenAI 兼容接口)
from agentweb_sdk import HTTPAdapter
plugin.use_adapter(HTTPAdapter("http://your-agent:8000"))

# 方式二:自定义处理函数
@plugin.handler
async def handle(message: str, session_id: str):
    return {"content": f"收到: {message}", "usage": {"input_tokens": 10, "output_tokens": 20}}

plugin.run()

运行后 SDK 会自动:

  • 通过 WebSocket 连接平台
  • 首次连接时完成自我介绍和自动注册
  • 保持心跳,断线自动重连

流式响应

@plugin.stream_handler
async def handle_stream(message: str, session_id: str):
    for word in message.split():
        yield {"content": word + " "}
    yield {"usage": {"input_tokens": 10, "output_tokens": 20}}

适配器

内置适配器,无需写处理函数:

from agentweb_sdk import HTTPAdapter, OpenClawAdapter

# OpenAI 兼容的 HTTP Agent
plugin.use_adapter(HTTPAdapter("http://localhost:8000"))

# OpenClaw Agent
plugin.use_adapter(OpenClawAdapter("http://localhost:9000"))

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

agentweb_sdk-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

agentweb_sdk-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file agentweb_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: agentweb_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.21

File hashes

Hashes for agentweb_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a6106850ae03525bf489ffd81308e556a2f39facdf05c340ddaa6bc6d76b2de8
MD5 7b6fbec4fb0cb8c652ead2a076675690
BLAKE2b-256 cc9ee3668fb4f906ce3e7db041fc8ddd5a8b69c464f5cb36bd5ba6af9f4a5918

See more details on using hashes here.

File details

Details for the file agentweb_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agentweb_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.21

File hashes

Hashes for agentweb_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52dd164707f9793e730d7f86eb02af6d5cc8b70122f312e9192a9eacf721455f
MD5 3196c1cf30d54025674391e8ae867204
BLAKE2b-256 e20e57fde081da68aa621fc38b91ca88547a4685233f7cef3b56b460a16b75fd

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