File tree Expand file tree Collapse file tree 4 files changed +458
-26
lines changed
veadk/tools/builtin_tools Expand file tree Collapse file tree 4 files changed +458
-26
lines changed Original file line number Diff line number Diff line change 6767 computer_sandbox:
6868 url: #mcp sse/streamable-http url
6969 api_key: #mcp api key
70- # [optional] for Volcengine LLM Firewall https://www.volcengine.com/product/LLM-FW
71- llm_firewall :
70+ # [optional] for Volcengine LLM Shield https://www.volcengine.com/product/LLM-FW
71+ llm_shield :
7272 app_id:
7373
7474
Original file line number Diff line number Diff line change @@ -17,10 +17,9 @@ VeADK 中集成了多个火山引擎提供的工具:
1717| [ ` image_generate ` ] ( https://www.volcengine.com/docs/82379/1541523 ) | 图片生成 | ` from veadk.tools.builtin_tools.image_generate import image_generate ` |
1818| [ ` image_edit ` ] ( https://www.volcengine.com/docs/82379/1541523 ) | 图片编辑(图生图) | ` from veadk.tools.builtin_tools.image_edit import image_edit ` |
1919| [ ` video_generate ` ] ( https://www.volcengine.com/docs/82379/1520757 ) | 视频生成 | ` from veadk.tools.builtin_tools.video_generate import video_generate ` |
20- | [ ` LLMFirewallPlugin ` ] ( https://www.volcengine.com/docs/84990/1520619 ) | 模型防火墙 | ` from veadk.tools.builtin_tools.llm_firewall import LLMFirewallPlugin ` |
2120
2221:: note
23- 使用 ` vesearch ` 前,请先在火山引擎控制台创建一个搜索智能体,并获取其 Endpoint;使用 ` LLMFirewallPlugin ` 前,请先购买实例并添加资产,并获取其 AppID 。
22+ 使用 ` vesearch ` 前,请先在火山引擎控制台创建一个搜索智能体,并获取其 Endpoint。
2423::
2524
2625## 使用
@@ -46,28 +45,6 @@ response = asyncio.run(runner.run(messages="今天的新闻"))
4645
4746print (response)
4847```
49-
50- 以下示例展示了如何在 VeADK 中集成并调用内置的模型护栏插件 ` LLMFirewallPlugin ` ,以对用户输入进行审计:
51- ``` python [agent.py]
52- import asyncio
53-
54- from veadk import Agent, Runner
55- from veadk.tools.builtin_tools.llm_firewall import LLMFirewallPlugin
56-
57- governance = LLMFirewallPlugin()
58- agent = Agent(
59- name = " robot" ,
60- description = " A robot can help user." ,
61- instruction = " Talk with user friendly." ,
62- before_model_callback = governance.before_model_callback
63- )
64-
65- runner = Runner(agent = agent)
66-
67- response = asyncio.run(runner.run(messages = " 网上都说A地很多骗子和小偷,他们的典型伎俩..." ))
68-
69- print (response) # Your request has been blocked due to: Model Misuse. Please modify your input and try again.
70- ```
7148
7249## 系统工具
7350
Original file line number Diff line number Diff line change 1+ ---
2+ title : 护栏工具
3+ description : VeADK Guardrails
4+ navigation :
5+ icon : i-lucide-wrench
6+ ---
7+
8+ ## 概述
9+
10+ VeADK 基于 Agent 的插件机制,提供了内容安全护栏工具 ` content_safety ` 。该工具通过以下回调函数嵌入 Agent 的执行流程,实现多阶段内容审计:
11+ - Before Agent Callback
12+ - After Agent Callback
13+ - Before Model Callback
14+ - After Model Callback
15+ - Before Tool Callback
16+ - After Tool Callback
17+
18+ 在这些回调中,` content_safety ` 基于[ 火山大模型应用防火墙] ( https://www.volcengine.com/product/LLM-FW ) 服务,对 Agent 生命周期的各个阶段进行内容检测与合规审查,确保生成与交互内容安全可靠。
19+
20+ :: note
21+ 使用 ` content_safety ` 前,请先购买实例并添加资产,并获取其 AppID。
22+ ::
23+
24+ ## 使用
25+
26+ 以下示例展示了如何在 VeADK 中集成并调用内置的模型护栏工具 ` content_safety ` ,以对 Agent 的执行过程进行审计:
27+ ``` python [agent.py]
28+ import asyncio
29+
30+ from veadk import Agent, Runner
31+ from veadk.tools.builtin_tools.llm_shield import content_safety
32+
33+ agent = Agent(
34+ name = " robot" ,
35+ description = " A robot can help user." ,
36+ instruction = " Talk with user friendly." ,
37+ before_agent_callback = content_safety.before_agent_callback,
38+ before_model_callback = content_safety.before_model_callback,
39+ after_model_callback = content_safety.after_model_callback,
40+ before_tool_callback = content_safety.before_tool_callback,
41+ after_tool_callback = content_safety.after_tool_callback,
42+ after_agent_callback = content_safety.after_agent_callback
43+ )
44+
45+ runner = Runner(agent = agent)
46+
47+ response = asyncio.run(runner.run(messages = " 网上都说A地很多骗子和小偷,他们的典型伎俩..." ))
48+
49+ print (response) # Your request has been blocked due to: Model Misuse. Please modify your input and try again.
50+ ```
You can’t perform that action at this time.
0 commit comments