Skip to main content

SDK for interacting with Autoagents.ai API

Project description

AutoAgents AI Python SDK

Python Version Version License

专业的 AutoAgents AI 平台 Python SDK,提供简洁易用的 API 接口,支持智能对话、文件处理、知识库管理等功能。

✨ 主要特性

  • 🤖 智能对话:流式对话,支持多轮交互和推理过程展示
  • 📁 文件处理:自动处理多种文件格式(PDF、Word、图片等)
  • 🗂️ 知识库管理:完整的知识库 CRUD 操作和内容搜索
  • 🎨 预构建智能体:PPT 生成、React Agent 等开箱即用的功能
  • 🌐 多模态支持:文本、图片、文件的统一处理接口
  • ⚡ 异步支持:高性能的异步 API 调用

🚀 快速开始

安装

pip install autoagentsai

或从源码安装:

git clone https://github.com/your-repo/autoagents-python-sdk.git
cd autoagents-python-sdk
pip install -e .

基础用法

智能对话

from autoagentsai.client import ChatClient

# 初始化客户端
client = ChatClient(
    agent_id="your_agent_id",
    personal_auth_key="your_auth_key", 
    personal_auth_secret="your_auth_secret"
)

# 发起对话
for event in client.invoke("你好,请介绍一下人工智能"):
    if event['type'] == 'token':
        print(event['content'], end='', flush=True)
    elif event['type'] == 'finish':
        break

文件分析

# 上传并分析文件
for event in client.invoke(
    prompt="请分析这个文档的主要内容",
    files=["document.pdf"]
):
    if event['type'] == 'token':
        print(event['content'], end='', flush=True)

知识库管理

from autoagentsai.client import KbClient

# 初始化知识库客户端
kb_client = KbClient(
    personal_auth_key="your_auth_key",
    personal_auth_secret="your_auth_secret"
)

# 创建知识库
result = kb_client.create_kb(
    name="技术文档库",
    description="存储技术相关文档"
)

# 查询知识库列表
kb_list = kb_client.query_kb_list()

PPT 生成

from autoagentsai.prebuilt import create_ppt_agent

# 创建 PPT 智能体
ppt_agent = create_ppt_agent()

# 填充 PPT 模板
ppt_agent.fill(
    prompt="关于人工智能发展的PPT",
    template_file_path="template.pptx",
    output_file_path="output.pptx"
)

📚 API 参考

ChatClient

主要的对话客户端,支持流式对话和多模态输入。

方法

  • invoke(prompt, images=None, files=None) - 发起对话
  • history() - 获取对话历史

事件类型

  • start_bubble - 新的回复气泡开始
  • token - 文本片段(用于打字机效果)
  • reasoning_token - AI 推理过程
  • end_bubble - 回复气泡结束
  • finish - 对话完成

KbClient

知识库管理客户端。

方法

  • create_kb(name, description) - 创建知识库
  • query_kb_list() - 查询知识库列表
  • get_kb_detail(kb_id) - 获取知识库详情
  • delete_kb(kb_id) - 删除知识库

🛠️ 环境要求

  • Python 3.11+
  • 依赖包:
    • pydantic>=2.11.7
    • requests>=2.32.4

🔧 配置

环境设置

# 测试环境(默认)
base_url = "https://uat.agentspro.cn"

# 生产环境
base_url = "https://agentspro.cn"

获取 API 密钥

  1. 登录 AutoAgents AI 平台
  2. 右上角 - 个人密钥
  3. 复制 personal_auth_keypersonal_auth_secret

获取 Agent ID

  1. 进入 Agent 详情页
  2. 点击"分享" - "API"
  3. 复制 Agent ID

📖 更多示例

查看 playground/ 目录获取更多使用示例:

  • playground/chat/ - 对话功能示例
  • playground/ppt/ - PPT 生成示例
  • playground/kb/ - 知识库管理示例
  • playground/react_agent/ - React Agent 示例

📄 许可证

MIT License

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📞 支持

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

autoagentsai-0.1.26.tar.gz (13.8 MB view details)

Uploaded Source

Built Distribution

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

autoagentsai-0.1.26-py3-none-any.whl (13.8 MB view details)

Uploaded Python 3

File details

Details for the file autoagentsai-0.1.26.tar.gz.

File metadata

  • Download URL: autoagentsai-0.1.26.tar.gz
  • Upload date:
  • Size: 13.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for autoagentsai-0.1.26.tar.gz
Algorithm Hash digest
SHA256 33a95be51e20491c4f0ab2510e0360f6673993db4e66d77be4a9ec389c952ec6
MD5 fef03648baccfd3b36212f9c9a8b732d
BLAKE2b-256 f6cb99f9b4471ad2aabe277be3109c67557fd2efe5b3677550669e021265e34d

See more details on using hashes here.

File details

Details for the file autoagentsai-0.1.26-py3-none-any.whl.

File metadata

File hashes

Hashes for autoagentsai-0.1.26-py3-none-any.whl
Algorithm Hash digest
SHA256 c67c30cb8e23d989c4ad478d0a8d7e47bce6b176c2cb5a31396f03738c9147cc
MD5 e0bb0d358b40d8c7ba9d052457bce93b
BLAKE2b-256 e4f3111d3c65177733648a306efad9b46adfc0574a7bd93e81b2065bdc4d6ca3

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