Files
higress/plugins/wasm-go/extensions/ai-intent/README.md
2024-09-12 21:48:40 +08:00

52 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: AI 意图识别
keywords: [ AI网关, AI意图识别 ]
description: AI 意图识别插件配置参考
---
## 功能说明
LLM 意图识别插件能够智能判断用户请求与某个领域或agent的功能契合度从而提升不同模型的应用效果和用户体验
## 运行属性
插件执行阶段:`默认阶段`
插件执行优先级:`700`
## 配置说明
> 1.该插件的优先级高于ai-proxy等后续使用意图的插件后续插件可以通过proxywasm.GetProperty([]string{"intent_category"})方法获取到意图主题,按照意图主题去做不同缓存库或者大模型的选择
> 2.需新建一条higress的大模型路由供该插件访问大模型,如:路由以 /intent 作为前缀服务选择大模型服务为该路由开启ai-proxy插件
> 3.需新建一个固定地址的服务intent-service服务指向127.0.0.1:80 (即自身网关实例+端口ai-intent插件内部需要该服务进行调用以访问上述新增的路由,服务名对应 llm.proxyServiceName也可以新建DNS类型服务使插件访问其他大模型
> 4.如果使用固定地址的服务调用网关自身需把127.0.0.1加入到网关的访问白名单中
| 名称 | 数据类型 | 填写要求 | 默认值 | 描述 |
| -------------- | --------------- | -------- | ------ | ------------------------------------------------------------ |
| `scene.category` | string | 必填 | - | 预设场景类别,以`|`分割,如:`金融|电商|法律|Higress`|
| `scene.prompt` | string | 非必填 | 你是一个智能类别识别助手,负责根据用户提出的问题和预设的类别,确定问题属于哪个预设的类别,并给出相应的类别。用户提出的问题为:%s,预设的类别为%s直接返回一种具体类别如果没有找到就返回'NotFound'。 | llm请求prompt模板 |
| `llm.proxyServiceName` | string | 必填 | - | 新建的higress服务指向大模型 (取higress中的 FQDN 值)|
| `llm.proxyUrl` | string | 必填 | - | 大模型路由请求地址全路径可以是网关自身的地址也可以是其他大模型的地址openai协议例如http://127.0.0.1:80/intent/compatible-mode/v1/chat/completions |
| `llm.proxyDomain` | string | 非必填 | proxyUrl中解析获取 | 大模型服务的domain|
| `llm.proxyPort` | string | 非必填 | proxyUrl中解析获取 | 大模型服务端口号 |
| `llm.proxyApiKey` | string | 非必填 | - | 当使用外部大模型服务时需配置 对应大模型的 API_KEY |
| `llm.proxyModel` | string | 非必填 | qwen-long | 大模型类型 |
| `llm.proxyTimeout` | number | 非必填 | 10000 | 调用大模型超时时间单位ms默认10000ms |
## 配置示例
```yaml
scene:
category: "金融|电商|法律|Higress"
prompt: "你是一个智能类别识别助手,负责根据用户提出的问题和预设的类别,确定问题属于哪个预设的类别,并给出相应的类别。用户提出的问题为:'%s',预设的类别为'%s',直接返回一种具体类别,如果没有找到就返回'NotFound'。"
llm:
proxyServiceName: "intent-service.static"
proxyUrl: "http://127.0.0.1:80/intent/compatible-mode/v1/chat/completions"
proxyDomain: "127.0.0.1"
proxyPort: "80"
proxyModel: "qwen-long"
proxyApiKey: ""
proxyTimeout: "10000"
```