Skip to content

Commit

Permalink
add ai plugins (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
rinfx authored Jun 19, 2024
1 parent 4708ae7 commit 76e9cf1
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: 1.0.0
info:
category: custom
name: ai-prompt-decorator
title: AI提示词修饰器
x-title-i18n:
zh-CN: AI提示词修饰器
description: 对LLM提示词进行修改
x-description-i18n:
zh-CN: 对LLM提示词进行修改
iconUrl: https://img.alicdn.com/imgextra/i1/O1CN018iKKih1iVx287RltL_!!6000000004419-2-tps-42-42.png
version: 1.0.0
contact:
name: rinfx
spec:
phase: UNSPECIFIED_PHASE
priority: 450
configSchema:
openAPIV3Schema:
type: object
example:
decorators:
- name: hangzhou-guide
decorator:
prepend:
- role: system
content: "你将使用英语回答问题"
- role: user
content: "假设你现在所在地点为杭州"
append:
- role: user
content: "在介绍杭州时,避开杭州的饮食"

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: 1.0.0
info:
category: custom
name: ai-prompt-template
title: AI提示词模板
x-title-i18n:
zh-CN: AI提示词模板
description: 基于模板构建LLM提示词
x-description-i18n:
zh-CN: 基于模板构建LLM提示词
iconUrl: https://img.alicdn.com/imgextra/i1/O1CN018iKKih1iVx287RltL_!!6000000004419-2-tps-42-42.png
version: 1.0.0
contact:
name: rinfx
spec:
phase: UNSPECIFIED_PHASE
priority: 500
configSchema:
openAPIV3Schema:
type: object
example:
templates:
- name: developer-chat
template:
model: gpt-3.5-turbo
messages:
- role: system
content: '你是一个 {{program}} 专家,编程语言为 {{language}}'
- role: user
content: '帮我写一个 {{program}} 程序'

33 changes: 33 additions & 0 deletions backend/sdk/src/main/resources/plugins/ai-rag/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: 1.0.0
info:
category: custom
name: ai-rag
title: AI检索增强生成
x-title-i18n:
zh-CN: AI检索增强生成
description: 通过RAG技术优化大模型生成内容
x-description-i18n:
zh-CN: 通过RAG技术优化大模型生成内容
iconUrl: https://img.alicdn.com/imgextra/i1/O1CN018iKKih1iVx287RltL_!!6000000004419-2-tps-42-42.png
version: 1.0.0
contact:
name: rinfx
spec:
phase: UNSPECIFIED_PHASE
priority: 400
configSchema:
openAPIV3Schema:
type: object
example:
dashscope:
apiKey: xxxxxxxxxxxxxxxxxxxx
serviceName: dashscope
servicePort: 443
domain: dashscope.aliyuncs.com
dashvector:
apiKey: xxxxxxxxxxxxxxxxxxxx
serviceName: dashvector
servicePort: 443
domain: vrs-cn-xxxxxxxxxxxxxxxxxxxx.dashvector.cn-hangzhou.aliyuncs.com
collection: news_embedings

28 changes: 28 additions & 0 deletions backend/sdk/src/main/resources/plugins/ai-security-guard/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: 1.0.0
info:
category: custom
name: ai-security-guard
title: AI内容安全
x-title-i18n:
zh-CN: AI内容安全
description: 基于阿里云内容安全对大模型的输入输出进行安全检测
x-description-i18n:
zh-CN: 基于阿里云内容安全对大模型的输入输出进行安全检测
iconUrl: https://img.alicdn.com/imgextra/i1/O1CN018iKKih1iVx287RltL_!!6000000004419-2-tps-42-42.png
version: 1.0.0
contact:
name: rinfx
spec:
phase: UNSPECIFIED_PHASE
priority: 300
configSchema:
openAPIV3Schema:
type: object
example:
serviceSource: dns
serviceName: safecheck
servicePort: 443
domain: green-cip.cn-shanghai.aliyuncs.com
ak: xxxxxxxxxxxxxxxxxxxx
sk: xxxxxxxxxxxxxxxxxxxx

23 changes: 23 additions & 0 deletions backend/sdk/src/main/resources/plugins/ai-statistics/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: 1.0.0
info:
category: custom
name: ai-statistics
title: AI可观测
x-title-i18n:
zh-CN: AI可观测
description: 生成AI可观测数据
x-description-i18n:
zh-CN: 生成AI可观测数据
iconUrl: https://img.alicdn.com/imgextra/i1/O1CN018iKKih1iVx287RltL_!!6000000004419-2-tps-42-42.png
version: 1.0.0
contact:
name: rinfx
spec:
phase: UNSPECIFIED_PHASE
priority: 200
configSchema:
openAPIV3Schema:
type: object
example:
enable: true

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: 1.0.0
info:
category: custom
name: ai-token-ratelimit
title: AI Token 限流
x-title-i18n:
zh-CN: AI Token 限流
description: 对大模型服务进行 Token 限流
x-description-i18n:
zh-CN: 对大模型服务进行 Token 限流
iconUrl: https://img.alicdn.com/imgextra/i1/O1CN018iKKih1iVx287RltL_!!6000000004419-2-tps-42-42.png
version: 1.0.0
contact:
name: rinfx
spec:
phase: UNSPECIFIED_PHASE
priority: 600
configSchema:
openAPIV3Schema:
type: object
example:
rule_name: default_rule
rule_items:
- limit_by_per_ip: from-remote-addr
limit_keys:
- key: 0.0.0.0/0
token_per_minute: 100
redis:
service_name: redis.static
service_port: 6379
username: default
password: '123456'

32 changes: 32 additions & 0 deletions backend/sdk/src/main/resources/plugins/ai-transformer/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: 1.0.0
info:
category: custom
name: ai-transformer
title: AI请求/响应转换
x-title-i18n:
zh-CN: AI请求/响应转换
description: 基于LLM对请求/响应进行智能转换
x-description-i18n:
zh-CN: 基于LLM对请求/响应进行智能转换
iconUrl: https://img.alicdn.com/imgextra/i1/O1CN018iKKih1iVx287RltL_!!6000000004419-2-tps-42-42.png
version: 1.0.0
contact:
name: rinfx
spec:
phase: UNSPECIFIED_PHASE
priority: 550
configSchema:
openAPIV3Schema:
type: object
example:
request:
enable: false
prompt: "如果请求path是以/httpbin开头的,帮我去掉/httpbin前缀,其他的不要改。"
response:
enable: true
prompt: "帮我修改以下HTTP应答信息,要求:1. content-type修改为application/json;2. body由xml转化为json;3.移除content-length。"
provider:
serviceName: qwen
domain: dashscope.aliyuncs.com
sk: sk-xxxxxxxxxxxxxxxxxxx

7 changes: 7 additions & 0 deletions backend/sdk/src/main/resources/plugins/plugins.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
# specific language governing permissions and limitations under the License.
#

ai-prompt-decorator=oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-prompt-decorator:1.0.0
ai-prompt-template=oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-prompt-template:1.0.0
ai-rag=oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-rag:1.0.0
ai-security-guard=oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-security-guard:1.0.0
ai-statistics=oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-statistics:1.0.0
ai-token-ratelimit=oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-token-ratelimit:1.0.0
ai-transformer=oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-transformer:1.0.0
ai-cache=oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-cache:1.0.0
ai-proxy=oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-proxy:1.0.0
basic-auth=oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/basic-auth:1.0.0
Expand Down

0 comments on commit 76e9cf1

Please sign in to comment.