Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions 02-use-cases/mini_aiops_copy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# AI运维 Agent - Mini AIOps

## 概述

> 本项目基于Veadk开发,实现了一个基于AI的运维智能工具

## 核心功能

本项目提供以下核心功能:

- 智能云资源巡检:自动梳理云上资源运行状态,发现潜在风险
- 一键问题诊断:结合日志、监控和主机诊断能力给出故障原因分析
- 运维知识问答:基于内置知识库回答常见运维问题和 SOP 流程
- 多 Agent 协同:通过 CCAPI 等 MCP 工具自动执行部分运维操作
- 长短期记忆:结合会话记忆与长期记忆提供持续性的运维助手体验

## Agent 能力

本项目当前内置一个总控 Agent 和一个子 Agent:

- ve_ai_ops_agent:面向云计算运维场景的总控 Agent,负责理解用户需求并规划巡检、诊断和优化流程。
- ccapi_agent:专注云资源管控的子 Agent,通过 CCAPI MCP 工具集查看和调整云上资源配置。

## 本地运行

### 环境准备

开始前,请确保您的开发环境满足以下要求:

- Python 3.10 或更高版本
- VeADK 0.2.28 或更高版本
- 推荐使用 `uv` 进行依赖管理
- <a target="_blank" href="https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey">获取火山方舟 API KEY</a>
- <a target="_blank" href="https://console.volcengine.com/iam/keymanage/">获取火山引擎 AK/SK</a>

### 快速入门

请按照以下步骤在本地部署和运行本项目。

#### 1. 下载代码并安装依赖

```bash
# 克隆代码仓库
git clone https://github.com/volcengine/agentkit-samples.git
cd agentkit-samples/02-use-cases/mini_aiops

# 安装项目依赖
uv sync --index-url https://pypi.tuna.tsinghua.edu.cn/simple
```

#### 2. 配置环境变量

```bash
export MODEL_AGENT_API_KEY="xxxxx"
export VOLCENGINE_ACCESS_KEY="xxxxxx"
export VOLCENGINE_SECRET_KEY="xxxxxx"
```

#### 4. 启动服务

1. 请先保证环境变量配置正确

2. 本地`veadk web`启动测试(注意:请保持在`agentkit-samples/02-use-cases`目录)

```bash
veadk web
```

1. 进入服务url `http://127.0.0.1:8000`
2. 选择`mini_aiops`
3. 与Agent进行对话

#### 5. 测试服务

![image1](./img/image1.png)

## 目录结构说明

```plaintext
mini_aiops/
├── agent.py # AIOps Agent 定义
├── README.md # 使用说明与功能介绍
├── requirements.txt# 依赖列表(基于 veadk-python)
├── pyproject.toml # 项目配置(uv/构建配置)
├── sop_aiops.md # 运维 SOP 文档(可导入到知识库)
├── img/ # README 中使用的示意截图
└── uv.lock # uv 生成的锁定文件
```

## AgentKit 部署

```bash
# 1. 进入`mini_aiops`
cd mini_aiops
# 2. 初始化配置
agentkit config
# 3. 根据说明进行配置
# 注意:第7步无需设置环境变量,第8步可以选择cloud模式

# 4. 部署
agentkit launch
```

部署过程完成后,由于运维MCP工具需要ECS相关权限,请前往控制台开通相关权限

进入控制台

![image4](./img/image4.png)

开通相关权限

![image5](./img/image5.png)

## 示例提示词

以下是一些常用的提示词示例:

"创建IAM用户"
"查看现有的ECS实例"
"列出可用的资源类型"
"更新某个资源的配置"

## 效果展示

部署中,控制台界面
![image2](./img/image2.png)
部署完成后,bash界面
![image3](./img/image3.png)

线上测试成功
![image6](./img/image6.png)

## 常见问题

常见问题列表待补充。

## 代码许可

本项目采用开源许可证,详情请参考项目根目录下的 LICENSE 文件。
1 change: 1 addition & 0 deletions 02-use-cases/mini_aiops_copy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .agent import root_agent # noqa
77 changes: 77 additions & 0 deletions 02-use-cases/mini_aiops_copy/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import os

from google.adk.planners import BuiltInPlanner
from google.adk.tools.mcp_tool.mcp_toolset import (
McpToolset,
StdioServerParameters,
StdioConnectionParams,
)
from google.genai import types
from veadk import Agent
from veadk.auth.veauth.utils import get_credential_from_vefaas_iam
from veadk.config import getenv # noqa
from veadk.knowledgebase.knowledgebase import KnowledgeBase
from veadk.memory.short_term_memory import ShortTermMemory
from agentkit.apps import AgentkitAgentServerApp

env_dict = {
"VOLCENGINE_ACCESS_KEY": os.getenv("VOLCENGINE_ACCESS_KEY"),
"VOLCENGINE_SECRET_KEY": os.getenv("VOLCENGINE_SECRET_KEY"),
}
if not (env_dict["VOLCENGINE_ACCESS_KEY"] and env_dict["VOLCENGINE_SECRET_KEY"]):
credential = get_credential_from_vefaas_iam()
env_dict["VOLCENGINE_ACCESS_KEY"] = credential.access_key_id
env_dict["VOLCENGINE_SECRET_KEY"] = credential.secret_access_key
env_dict["VOLCENGINE_SESSION_TOKEN"] = credential.session_token

short_term_memory = ShortTermMemory(backend="local")

### Auto create knowledgebase if not exist for aiops
knowledgebase = KnowledgeBase(backend="local", index="aiops_kb", top_k=3)

file_path = os.path.join(os.path.dirname(__file__), "sop_aiops.md")
knowledgebase.add_from_files(files=[file_path])

### control center mcp server
server_parameters = StdioServerParameters(
command="uvx",
args=[
"--from",
"git+https://github.com/volcengine/mcp-server#subdirectory=server/mcp_server_ccapi",
"mcp-server-ccapi",
],
env=env_dict,
)

ccapi_mcp_toolset = McpToolset(
connection_params=StdioConnectionParams(
server_params=server_parameters, timeout=180.0
),
errlog=None,
)

agent: Agent = Agent(
name="root_agent",
model_name="deepseek-v3-1-terminus",
description="云资源管控智能体",
instruction="你是一个云资源管控专家,擅长通过 CCAPI 管理各类云资源",
knowledgebase=knowledgebase,
tools=[ccapi_mcp_toolset],
planner=BuiltInPlanner(
thinking_config=types.ThinkingConfig(
include_thoughts=False,
thinking_budget=0,
)
),
)

root_agent = agent


agent_server_app = AgentkitAgentServerApp(
agent=agent,
short_term_memory=short_term_memory,
)

if __name__ == "__main__":
agent_server_app.run(host="0.0.0.0", port=8000)
13 changes: 13 additions & 0 deletions 02-use-cases/mini_aiops_copy/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail

agentkit config \
--agent_name mini_aiops \
--entry_point agent.py \
--description "a mini agent for aiops" \
--launch_type cloud \
--image_tag v1.0.0 \
--region cn-beijing

agentkit launch

Binary file added 02-use-cases/mini_aiops_copy/img/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 02-use-cases/mini_aiops_copy/img/image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 02-use-cases/mini_aiops_copy/img/image3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 02-use-cases/mini_aiops_copy/img/image4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 02-use-cases/mini_aiops_copy/img/image5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 02-use-cases/mini_aiops_copy/img/image6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions 02-use-cases/mini_aiops_copy/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[project]
name = "mini-aiops"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"agentkit-sdk-python>=0.2.0",
"veadk-python==0.5.0",
]
2 changes: 2 additions & 0 deletions 02-use-cases/mini_aiops_copy/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
agentkit-sdk-python>=0.2.0
veadk-python==0.5.0
Loading