Skip to content

Commit 64aec7c

Browse files
committed
update docs
1 parent 8dd79e9 commit 64aec7c

220 files changed

Lines changed: 7155 additions & 20965 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/.gitignore

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
develop-eggs/
12+
dist/
13+
downloads/
14+
eggs/
15+
.eggs/
16+
lib/
17+
lib64/
18+
parts/
19+
sdist/
20+
var/
21+
wheels/
22+
share/python-wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.nox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*.cover
48+
*.py,cover
49+
.hypothesis/
50+
.pytest_cache/
51+
cover/
52+
53+
# Translations
54+
*.mo
55+
*.pot
56+
57+
# Django stuff:
58+
*.log
59+
local_settings.py
60+
db.sqlite3
61+
db.sqlite3-journal
62+
63+
# Flask stuff:
64+
instance/
65+
.webassets-cache
66+
67+
# Scrapy stuff:
68+
.scrapy
69+
70+
# Sphinx documentation
71+
docs/_build/
72+
73+
# PyBuilder
74+
.pybuilder/
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
# For a library or package, you might want to ignore these files since the code is
86+
# intended to run in multiple environments; otherwise, check them in:
87+
# .python-version
88+
89+
# pipenv
90+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
91+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
92+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
93+
# install all needed dependencies.
94+
#Pipfile.lock
95+
96+
# poetry
97+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
98+
# This is especially recommended for binary packages to ensure reproducibility, and is more
99+
# commonly ignored for libraries.
100+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
101+
#poetry.lock
102+
103+
# pdm
104+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
105+
#pdm.lock
106+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
107+
# in version control.
108+
# https://pdm.fming.dev/#use-with-ide
109+
.pdm.toml
110+
111+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
112+
__pypackages__/
113+
114+
# Celery stuff
115+
celerybeat-schedule
116+
celerybeat.pid
117+
118+
# SageMath parsed files
119+
*.sage.py
120+
121+
# Environments
122+
.env
123+
.venv
124+
env/
125+
venv/
126+
ENV/
127+
env.bak/
128+
venv.bak/
129+
130+
# Spyder project settings
131+
.spyderproject
132+
.spyproject
133+
134+
# Rope project settings
135+
.ropeproject
136+
137+
# mkdocs documentation
138+
/site
139+
140+
# mypy
141+
.mypy_cache/
142+
.dmypy.json
143+
dmypy.json
144+
145+
# Pyre type checker
146+
.pyre/
147+
148+
# pytype static type analyzer
149+
.pytype/
150+
151+
# Cython debug symbols
152+
cython_debug/
153+
154+
# PyCharm
155+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
156+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
157+
# and can be added to the global gitignore or merged into this file. For a more nuclear
158+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
159+
.idea/
160+
161+
# vscode
162+
.vscode/
163+
# Windsurf
164+
.windsurf
165+
166+
# python package
167+
uv.lock
168+
169+
# VitePress related files (security concern - keep Markdown docs in repo)
170+
docs/package.json
171+
docs/package-lock.json
172+
docs/node_modules/

docs/app/app_agent.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: app_agent
2+
description: Application operations agent.
3+
instruction: 仅根据你的知识库回答业务应用排障问题。必要时建议回滚或触发标准化作业。
4+
model: itops_root.models.MockSubAgentLlm

docs/app/host_agent.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: host_agent
2+
description: Host/Middleware operations agent.
3+
instruction: 仅根据你的知识库回答主机/中间件排障问题。必要时建议采集证据或提交工单。
4+
model: itops_root.models.MockSubAgentLlm

docs/app/itops_root.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: itops_root
2+
description: Planner that routes user intents to the right department agent.
3+
instruction: |
4+
你是 IT 运维总控台。先判断用户问题属于 网络/主机/应用/安全 哪一类,
5+
然后调用相应子 Agent 获取答案并整合。若问题跨域,可分别调用多个子 Agent 并给出综合结论。
6+
若涉及动作(如创建工单),请明确说明,并在获得用户确认后再调用相关工具。
7+
tools:
8+
- tools.py
9+
sub_agents:
10+
- network_agent.yaml
11+
- host_agent.yaml
12+
- app_agent.yaml
13+
- sec_agent.yaml
14+
model:
15+
name: mock-planner
16+
long_term_memory:
17+
backend: local
18+
index: itops_ltm_demo
19+
tracers:
20+
- type: opentelemetry

docs/app/itops_root/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from google.adk.tools.tool_registry import register_tool
2+
from . import models
3+
from . import tools
4+
5+
register_tool(tools.create_ticket)
6+
register_tool(tools.query_cmdb)

docs/app/itops_root/models.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
from google.adk.models.base_llm import BaseLlm
2+
from google.adk.models.llm_response import LlmResponse
3+
from google.genai import types as genai_types
4+
5+
class MockPlannerLlm(BaseLlm):
6+
"""A mock planner LLM that routes to sub-agents based on keywords."""
7+
8+
async def generate_content_async(self, llm_request, stream: bool = False):
9+
user_queries: list[str] = []
10+
for content in llm_request.contents:
11+
if content.role == "user":
12+
for part in content.parts or []:
13+
if getattr(part, "text", None):
14+
user_queries.append(part.text)
15+
query = user_queries[-1] if user_queries else ""
16+
17+
function_calls = []
18+
if "网络" in query or "network" in query:
19+
function_calls.append(
20+
genai_types.FunctionCall(
21+
name="network_agent",
22+
args={"prompt": query}
23+
)
24+
)
25+
if "服务器" in query or "主机" in query or "host" in query:
26+
function_calls.append(
27+
genai_types.FunctionCall(
28+
name="host_agent",
29+
args={"prompt": query}
30+
)
31+
)
32+
if "应用" in query or "app" in query:
33+
function_calls.append(
34+
genai_types.FunctionCall(
35+
name="app_agent",
36+
args={"prompt": query}
37+
)
38+
)
39+
if "安全" in query or "sec" in query:
40+
function_calls.append(
41+
genai_types.FunctionCall(
42+
name="sec_agent",
43+
args={"prompt": query}
44+
)
45+
)
46+
47+
if function_calls:
48+
parts = [genai_types.Part(function_call=call) for call in function_calls]
49+
response_content = genai_types.Content(
50+
role="model",
51+
parts=parts,
52+
)
53+
else:
54+
text = f"抱歉,无法理解您的问题 '{query}'。请说明问题属于 网络/主机/应用/安全 中的哪一类。"
55+
response_content = genai_types.Content(
56+
role="model",
57+
parts=[genai_types.Part.from_text(text=text)],
58+
)
59+
60+
yield LlmResponse(content=response_content)
61+
62+
class MockSubAgentLlm(BaseLlm):
63+
"""A mock sub-agent LLM that provides a canned response."""
64+
65+
async def generate_content_async(self, llm_request, stream: bool = False):
66+
# Extract the function call from the request
67+
function_call = None
68+
for content in llm_request.contents:
69+
if content.role == "function":
70+
function_call = content
71+
72+
if function_call:
73+
response_text = f"已收到来自 {function_call.parts[0].function_response.name} 的请求"
74+
else:
75+
response_text = "已收到请求"
76+
77+
78+
response_content = genai_types.Content(
79+
role="model",
80+
parts=[genai_types.Part.from_text(text=response_text)],
81+
)
82+
83+
yield LlmResponse(content=response_content)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: itops_root
2+
description: Planner that routes user intents to the right department agent.
3+
instruction: |
4+
你是 IT 运维总控台。先判断用户问题属于 网络/主机/应用/安全 哪一类,
5+
然后调用相应子 Agent 获取答案并整合。若问题跨域,可分别调用多个子 Agent 并给出综合结论。
6+
若涉及动作(如创建工单),请明确说明,并在获得用户确认后再调用相关工具。
7+
sub_agents:
8+
- config_path: ../network_agent.yaml
9+
- config_path: ../host_agent.yaml
10+
- config_path: ../app_agent.yaml
11+
- config_path: ../sec_agent.yaml
12+
tools:
13+
- name: itops_root.tools.create_ticket
14+
- name: itops_root.tools.query_cmdb
15+
model: itops_root.models.MockPlannerLlm

docs/app/itops_root/tools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from typing import Dict, Any, Optional
2+
3+
def create_ticket(type: str, title: str, severity: str, meta: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
4+
"""创建工单(示例桩)。生产中调用企业工单系统 API,并返回工单链接。"""
5+
ticket_id = f"TCK-{severity.upper()}-0001"
6+
return {"id": ticket_id, "url": f"https://ticket.example.com/{ticket_id}", "title": title, "type": type, "severity": severity, "meta": meta or {}}
7+
8+
def query_cmdb(asset_id: Optional[str] = None, ip: Optional[str] = None) -> Dict[str, Any]:
9+
"""CMDB 查询(示例桩)。生产中调用 CMDB API。"""
10+
return {"asset_id": asset_id or "host-001", "ip": ip or "10.0.0.1", "owner_dept": "network", "env": "prod"}

docs/app/network_agent.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: network_agent
2+
description: Network operations agent focusing on DNS/Connectivity.
3+
instruction: 仅根据你的知识库回答网络排障问题。不要臆测,不要编造。必要时建议提交工单。
4+
model: itops_root.models.MockSubAgentLlm

docs/app/sec_agent.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: sec_agent
2+
description: Security operations agent.
3+
instruction: 仅根据你的知识库回答安全相关问题。对可能的失陷要给出初步处置建议。
4+
model: itops_root.models.MockSubAgentLlm

0 commit comments

Comments
 (0)