Skip to main content

A Python SDK for interacting with Seele Agent services

Project description

Seele SDK

Seele SDK 是一个用于与 Seele Agent 服务交互的 Python 工具包。它提供了一个简单的接口,用于与 AI 代理进行通信,包括思考、图像处理和自定义能力调用等功能。

安装

使用 pip 安装:

pip install seele-sdk

运行模式

SDK 有两种运行模式:

1. 平台模式

在 Seele 平台环境中运行时:

  • Agent 信息会由平台自动注入
  • 无需手动配置任何信息
  • 必须在 Agent 配置面板中启用相应的能力才能调用
  • 默认 base_url 为 http://127.0.0.1:8086

2. 本地开发模式

在本地开发和测试时:

  • 需要手动提供 agent_info 字典(至少包含 id 字段)
  • 确保调用的能力已在 Agent 配置面板中启用
  • 可以根据需要覆盖 base_url

快速开始

以下是使用 SDK 的简单示例:

from seele_sdk import AgentContext

# 本地开发:模拟 agent_info
agent_info = {
    "id": 53,  # 必需字段
    "name": "会议室302记录助手",  # 可选
    "description": "用于监控302会议室的助手",  # 可选
    "capabilities": {  # 可选
        "space_analysis": ["body_detection", "multimodal_vision"]
    }
}

# 使用上下文管理器(使用默认 base_url: http://127.0.0.1:8086)
with AgentContext(agent_info) as ctx:
    # 发送思考请求
    response = ctx.think("会议室现在是什么状态?")
    print(response)
    
    # 处理图片
    image_urls = ["http://example.com/image1.jpg"]
    response = ctx.look("描述一下这张图片中的内容", image_urls)
    print(response)
    
    # 清除 Agent 记忆
    # 可以清除所有记忆或指定会话的记忆
    result = ctx.clear_memory()  # 清除所有记忆
    # 或者
    result = ctx.clear_memory(session_id="session_123")  # 清除指定会话的记忆
    print(result)

最简配置

在本地开发时,如果只需要基本功能,可以只提供 id:

from seele_sdk import AgentContext

# 最简配置
with AgentContext({"id": 53}) as ctx:
    response = ctx.think("你好")
    print(response)

直接使用 AgentSDK

如果你不想使用上下文管理器,可以直接使用 SDK:

from seele_sdk import AgentSDK

# 初始化 SDK(使用默认 base_url)
sdk = AgentSDK(base_url="http://127.0.0.1:8086", agent_id=53)

# 发送思考请求
response = sdk.think("当前状态如何?")

# 处理图片
response = sdk.look("描述这张图片", ["http://example.com/image1.jpg"])

# 调用能力(需要在 Agent 配置中启用)
result = sdk.call_ability("namespace", "ability_name", "arg1", "arg2")

# 清除 Agent 记忆
result = sdk.clear_memory()  # 清除所有记忆
# 或者
result = sdk.clear_memory(session_id="session_123")  # 清除指定会话的记忆

关于能力的重要说明

  1. 能力配置

    • 必须在 Agent 配置面板中启用相应的能力才能调用
    • 调用未配置的能力会导致错误
    • 本地开发时可以在 agent_info 中列出能力,但这只是为了参考
  2. 平台模式 vs 本地开发

    • 平台模式:所有配置由平台自动注入,无需手动设置
    • 本地开发:只需提供必要的 agent_info(至少包含 id)

错误处理

SDK 内置了错误处理和日志记录功能:

import logging

# 配置日志
logging.basicConfig(level=logging.INFO)

try:
    with AgentContext({"id": 53}) as ctx:
        response = ctx.think("你好")
except Exception as e:
    print(f"发生错误: {e}")

贡献

欢迎提交 Pull Request 来改进这个项目!

许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件。

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

seele_sdk-0.1.4.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

seele_sdk-0.1.4-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file seele_sdk-0.1.4.tar.gz.

File metadata

  • Download URL: seele_sdk-0.1.4.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for seele_sdk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 57b5f059bd3b03a3b9bdfc137dfd331354b91833e6a51942eaf6018d85b8c166
MD5 78d419d545b86529b2fbdfd9c01cfb4a
BLAKE2b-256 9168d34aa774568a6ca135ba8980823036f161255a7675048db37dbc3df97c28

See more details on using hashes here.

File details

Details for the file seele_sdk-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: seele_sdk-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for seele_sdk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 15145db06680d3e99ce27652157b0007554c392c9f22cd581d90b892f53280fd
MD5 c326403ca5f71109eecd28f631460756
BLAKE2b-256 20460240e0aa60bbe4cf40b964935feebfe9017491628688a8d6c8f8afd6a518

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