Skip to main content

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

Release files for agentweb-sdk 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentweb-sdk 0.1.1
File Size Uploaded
agentweb_sdk-0.1.1.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentweb-sdk 0.1.1
File Interpreter ABI Platform
agentweb_sdk-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.3 kB

Release files / agentweb_sdk-0.1.1.tar.gz

Download URL agentweb_sdk-0.1.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fe7d4233e3bad8c38c6f2e9d65563c3021d52e90a015d4bc2c24cb34724471ea
BLAKE2b-256 checksum
How to use checksums
20886c5fd3ed957d305bc3422571c247d9cf600859e2357040b4b9d5689b7967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.21

Release files / agentweb_sdk-0.1.1-py3-none-any.whl

Download URL agentweb_sdk-0.1.1-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c095d22a5b96224b44d3446a219452382b21bc7840b1377d9746850b321288a8
BLAKE2b-256 checksum
How to use checksums
886f60624b348dd9218ac360b7b81a6fb94c86afb98f65982e98dcbf930c034e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page