File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -17,9 +17,10 @@ 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 ` |
2021
2122:: note
22- 使用 ` vesearch ` 前,请先在火山引擎控制台创建一个搜索智能体,并获取其 Endpoint。
23+ 使用 ` vesearch ` 前,请先在火山引擎控制台创建一个搜索智能体,并获取其 Endpoint;使用 ` LLMFirewallPlugin ` 前,请先购买实例并添加资产,并获取其 AppID 。
2324::
2425
2526## 使用
@@ -45,6 +46,28 @@ response = asyncio.run(runner.run(messages="今天的新闻"))
4546
4647print (response)
4748```
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+ ```
4871
4972## 系统工具
5073
You can’t perform that action at this time.
0 commit comments