Skip to main content

Agent Server

一个基于 Google ADK (Agent Development Kit) 和 FastAPI 构建的智能体服务服务器,用于运行和管理 AI 代理。

项目概述

agent-server 提供了多种接口方式来与 AI 代理进行交互,包括 HTTP API、AGUI 接口和命令行界面。

核心功能

1. ADK Server

基于 FastAPI 的 HTTP API 服务器,使用 Google ADK 的 Runner 来执行代理。

  • 功能: 提供标准的 HTTP API 接口
  • 会话管理: 支持会话创建和管理
  • 安全: 包含用户白名单中间件
  • 启动命令: agent-server-adk

配置文件参数说明: AGENTS_PATH=/Users/fubo/develop/apps/agent-os # 智能体配置的上一级文件夹 SESSION_SERVICE_URI=sqlite+aiosqlite:///./sessions.db # Session服务的链接 MEMORY_SERVICE_URI=milvus+http: # Memory服务的链接(backend支持内存【空字符串】、Milvus【milvus】) EMBEDDING_BASE_URL="http://localhost:8000/v1" # embedding服务的base url EMBEDDING_API_KEY="sk-XXX" # embedding服务的API-KEY EMBEDDING_MODEL="" # embedding模型名称 USER_SERVICE_URI= # 用户服务的URI TRACE_SERVICE_URI=test@http://101.42.12.55:20500 # 智能体trace服务的URI HOST=0.0.0.0 # 服务IP PORT=8000 # 服务端口 ASYNC_CHAT_MAX_CONCURRENCY=4 # 异步提交最大job的数量 ASYNC_CHAT_MAX_TASK_EVENTS=2000 # 异步提交最大的event数量

2. AGUI Server

提供 AGUI (Agent Graphical User Interface) 接口,用于图形化交互。

  • 主要端点:
    • POST /agui/api/v1/chat/completions - 聊天完成接口
    • GET /agui/api/v1/reload - 热重载代理配置
    • GET /agui/api/v1/health - 健康检查
  • 启动命令: agent-server-agui

3. CMD Server

命令行交互界面,使用 rich 库实现彩色输出和 Markdown 渲染。

  • 功能:
    • 任务提交和执行
    • 会话管理(列出、删除)
    • 实时输出代理响应
    • 支持工具调用和函数响应展示
  • 启动命令: agent-server-cmd

技术架构

依赖

  • Google ADK: Agent Development Kit,用于代理运行
  • FastAPI: Web 框架,提供 HTTP API
  • Uvicorn: ASGI 服务器
  • Rich: 命令行美化输出
  • Python Dotenv: 环境变量管理

工具类 (utils.py)

  • Utils.Service: 提供 session 和 memory 服务的创建
    • memory_service(): 创建记忆服务
    • session_service(): 创建会话服务
  • Utils.Agent: 负责代理的加载和运行器创建
    • load_adk_agents(): 从指定路径加载代理配置
    • create_adk_agent_agui_runner(): 创建 AGUI 运行器
    • create_adk_agent_adk_runner(): 创建 ADK 运行器

配置说明

配置文件:.server.env

# 代理配置路径
AGENTS_PATH=/Users/fubo/develop/apps/agent-os/agents

# 会话服务数据库 URI(留空使用内存服务)
SESSION_SERVICE_URI=

# 记忆服务 URI(留空使用内存服务)
MEMORY_SERVICE_URI=

# 用户服务 URI
USER_SERVICE_URI=

# 追踪服务 URI
TRACE_SERVICE_URI=

# 服务器监听地址
HOST=0.0.0.0

# 服务器端口
PORT=8000

安装与使用

安装依赖

pip install -e .

启动服务

# 启动 AGUI 服务器
agent-server-agui

# 启动命令行界面
agent-server-cmd

# 启动 ADK 服务器
agent-server-adk

项目结构

agent-server/
├── src/
│   └── agent_server/
│       ├── __init__.py
│       ├── adk_server.py      # ADK HTTP 服务器
│       ├── agui_server.py     # AGUI 服务器
│       ├── cmd_server.py      # 命令行服务器
│       ├── utils.py           # 工具类
│       └── .server.env        # 配置文件
├── tests/
├── pyproject.toml
├── Dockerfile
└── README.md

开发信息

  • 版本: 0.0.1
  • 作者: fubo fb_linux@163.com
  • 许可证: MIT
  • Python 版本: >= 3.10

依赖项

  • agent-base>=0.1.2
  • fastapi
  • uvicorn
  • rich
  • python-dotenv
  • google-adk

测试

pip install -e ".[test]"
pytest

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_os_server-0.5.10.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

agent_os_server-0.5.10-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file agent_os_server-0.5.10.tar.gz.

File metadata

  • Download URL: agent_os_server-0.5.10.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for agent_os_server-0.5.10.tar.gz
Algorithm Hash digest
SHA256 50a774f75a3001ee0842bb6250ba1c13fc8fbd79ec2795acb87f245285c40038
MD5 64b83844f1c027d60d4b91a4f78c747b
BLAKE2b-256 3cb69cd621063af914691e955007d8e96244adc1696ca29cd93ae9b21a0d9b2f

See more details on using hashes here.

File details

Details for the file agent_os_server-0.5.10-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_os_server-0.5.10-py3-none-any.whl
Algorithm Hash digest
SHA256 dcf2a811b87b04d8d7fdbafcfe5fa0c8464ab00c1c0c9b588c309d09c2c6187f
MD5 655db9ed10cdf184767da1cf0b41c0cf
BLAKE2b-256 aaffcb6add46d18344351fcee77abef1bddfddfda666e962f2fc4c22006cd139

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.10 This release

2 files

0.5.9

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.0.15

2 files

0.0.14

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page