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.1.tar.gz (7.7 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.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agentweb_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 7.7 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.1.tar.gz
Algorithm Hash digest
SHA256 fe7d4233e3bad8c38c6f2e9d65563c3021d52e90a015d4bc2c24cb34724471ea
MD5 b83afaad95d8bc80d38dd0e8ac12cf78
BLAKE2b-256 20886c5fd3ed957d305bc3422571c247d9cf600859e2357040b4b9d5689b7967

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agentweb_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c095d22a5b96224b44d3446a219452382b21bc7840b1377d9746850b321288a8
MD5 fe62d8401ee28fc67c649954ae1c5749
BLAKE2b-256 886f60624b348dd9218ac360b7b81a6fb94c86afb98f65982e98dcbf930c034e

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