Skip to content

Commit 58620c6

Browse files
authored
feat: add json schema for plugins (higress-group#560)
1 parent 0e2e242 commit 58620c6

File tree

40 files changed

+8034
-65
lines changed

40 files changed

+8034
-65
lines changed

backend/sdk/src/main/resources/plugins/ai-agent/spec.yaml

Lines changed: 595 additions & 1 deletion
Large diffs are not rendered by default.

backend/sdk/src/main/resources/plugins/ai-cache/spec.yaml

Lines changed: 233 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ info:
44
category: ai
55
image: platform_wasm/ai-cache
66
name: ai-cache
7-
title: AI Cache
7+
title: AI 缓存
88
x-title-i18n:
9-
zh-CN: AI 缓存
10-
description: Cache the response of large language models, significantly reduce the response latency of similar problems and save costs.
9+
en-US: AI Cache
10+
description: 缓存大语言模型的响应结果,显著降低相似问题的响应时延并节省成本。
1111
x-description-i18n:
12-
zh-CN: 缓存大语言模型的响应结果,显著降低相似问题的响应时延并节省成本。
12+
en-US: Cache the response of large language models, significantly reduce the response latency of similar problems and save costs.
1313
iconUrl: https://img.alicdn.com/imgextra/i1/O1CN018iKKih1iVx287RltL_!!6000000004419-2-tps-42-42.png
1414
version: 1.0.0
1515
contact:
@@ -21,6 +21,120 @@ spec:
2121
configSchema:
2222
openAPIV3Schema:
2323
type: object
24+
properties:
25+
cacheKeyFrom:
26+
type: string
27+
title: 从请求 Body 中提取缓存 Key
28+
x-title-i18n:
29+
en-US: Cache Key From Request Body
30+
description: 从请求 Body 中基于 GJSON PATH 语法提取字符串
31+
x-description-i18n:
32+
en-US: Extract a string from the request Body based on GJSON PATH syntax
33+
default: "messages.@reverse.0.content"
34+
cacheValueFrom:
35+
type: string
36+
title: 从响应 Body 中提取缓存值
37+
x-title-i18n:
38+
en-US: Cache Value From Response Body
39+
description: 从响应 Body 中基于 GJSON PATH 语法提取字符串
40+
x-description-i18n:
41+
en-US: Extract a string from the response Body based on GJSON PATH syntax
42+
default: "choices.0.message.content"
43+
cacheStreamValueFrom:
44+
type: string
45+
title: 从流式响应 Body 中提取缓存值
46+
x-title-i18n:
47+
en-US: Cache Value From Stream Response Body
48+
description: 从流式响应 Body 中基于 GJSON PATH 语法提取字符串
49+
x-description-i18n:
50+
en-US: Extract a string from the streaming response Body based on GJSON PATH syntax
51+
default: "choices.0.delta.content"
52+
cacheKeyPrefix:
53+
type: string
54+
title: 缓存 Key 前缀
55+
x-title-i18n:
56+
en-US: Cache Key Prefix
57+
description: Redis缓存Key的前缀
58+
x-description-i18n:
59+
en-US: Prefix for the Redis cache key
60+
default: "higress-ai-cache:"
61+
cacheTTL:
62+
type: integer
63+
title: 缓存过期时间
64+
x-title-i18n:
65+
en-US: Cache TTL
66+
description: 缓存的过期时间,单位是秒,默认值为0,即永不过期
67+
x-description-i18n:
68+
en-US: Cache expiration time in seconds, default value is 0, which means never expire
69+
default: 0
70+
redis:
71+
type: object
72+
title: Redis 配置
73+
x-title-i18n:
74+
en-US: Redis Configuration
75+
properties:
76+
serviceName:
77+
type: string
78+
title: Redis 服务名称
79+
x-title-i18n:
80+
en-US: Redis Service Name
81+
description: redis 服务名称,带服务类型的完整 FQDN 名称
82+
x-description-i18n:
83+
en-US: The complete FQDN name of the Redis service, including the service type
84+
servicePort:
85+
type: integer
86+
title: Redis 服务端口
87+
x-title-i18n:
88+
en-US: Redis Service Port
89+
description: redis 服务端口
90+
x-description-i18n:
91+
en-US: Redis service port
92+
default: 6379
93+
timeout:
94+
type: integer
95+
title: Redis 超时时间
96+
x-title-i18n:
97+
en-US: Redis Timeout
98+
description: 请求 redis 的超时时间,单位为毫秒
99+
x-description-i18n:
100+
en-US: Timeout for requests to Redis, in milliseconds
101+
default: 1000
102+
username:
103+
type: string
104+
title: Redis 用户名
105+
x-title-i18n:
106+
en-US: Redis Username
107+
description: 登陆 redis 的用户名
108+
x-description-i18n:
109+
en-US: Username for logging into Redis
110+
password:
111+
type: string
112+
title: Redis 密码
113+
x-title-i18n:
114+
en-US: Redis Password
115+
description: 登陆 redis 的密码
116+
x-description-i18n:
117+
en-US: Password for logging into Redis
118+
required:
119+
- serviceName
120+
returnResponseTemplate:
121+
type: string
122+
title: 响应模板
123+
x-title-i18n:
124+
en-US: Response Template
125+
description: 返回 HTTP 响应的模版,用 %s 标记需要被 cache value 替换的部分
126+
x-description-i18n:
127+
en-US: Template for returning HTTP response, with %s marking the part to be replaced by cache value
128+
default: '{"id":"from-cache","choices":[%s],"model":"gpt-4o","object":"chat.completion","usage":{"prompt_tokens":0,"completion_tokens":0,"total_tokens":0}}'
129+
returnStreamResponseTemplate:
130+
type: string
131+
title: 流式响应模板
132+
x-title-i18n:
133+
en-US: Stream Response Template
134+
description: 返回流式 HTTP 响应的模版,用 %s 标记需要被 cache value 替换的部分
135+
x-description-i18n:
136+
en-US: Template for returning streaming HTTP response, with %s marking the part to be replaced by cache value
137+
default: 'data:{"id":"from-cache","choices":[{"index":0,"delta":{"role":"assistant","content":"%s"},"finish_reason":"stop"}],"model":"gpt-4o","object":"chat.completion","usage":{"prompt_tokens":0,"completion_tokens":0,"total_tokens":0}}\n\ndata:[DONE]\n\n'
24138
example:
25139
redis:
26140
serviceName: my-redis.dns
@@ -37,8 +151,122 @@ spec:
37151
routeConfigSchema:
38152
openAPIV3Schema:
39153
type: object
40-
example:
154+
properties:
155+
cacheKeyFrom:
156+
type: string
157+
title: 从请求 Body 中提取缓存 Key
158+
x-title-i18n:
159+
en-US: Cache Key From Request Body
160+
description: 从请求 Body 中基于 GJSON PATH 语法提取字符串
161+
x-description-i18n:
162+
en-US: Extract a string from the request Body based on GJSON PATH syntax
163+
default: "messages.@reverse.0.content"
164+
cacheValueFrom:
165+
type: string
166+
title: 从响应 Body 中提取缓存值
167+
x-title-i18n:
168+
en-US: Cache Value From Response Body
169+
description: 从响应 Body 中基于 GJSON PATH 语法提取字符串
170+
x-description-i18n:
171+
en-US: Extract a string from the response Body based on GJSON PATH syntax
172+
default: "choices.0.message.content"
173+
cacheStreamValueFrom:
174+
type: string
175+
title: 从流式响应 Body 中提取缓存值
176+
x-title-i18n:
177+
en-US: Cache Value From Stream Response Body
178+
description: 从流式响应 Body 中基于 GJSON PATH 语法提取字符串
179+
x-description-i18n:
180+
en-US: Extract a string from the streaming response Body based on GJSON PATH syntax
181+
default: "choices.0.delta.content"
182+
cacheKeyPrefix:
183+
type: string
184+
title: 缓存 Key 前缀
185+
x-title-i18n:
186+
en-US: Cache Key Prefix
187+
description: Redis缓存Key的前缀
188+
x-description-i18n:
189+
en-US: Prefix for the Redis cache key
190+
default: "higress-ai-cache:"
191+
cacheTTL:
192+
type: integer
193+
title: 缓存过期时间
194+
x-title-i18n:
195+
en-US: Cache TTL
196+
description: 缓存的过期时间,单位是秒,默认值为0,即永不过期
197+
x-description-i18n:
198+
en-US: Cache expiration time in seconds, default value is 0, which means never expire
199+
default: 0
41200
redis:
201+
type: object
202+
title: Redis 配置
203+
x-title-i18n:
204+
en-US: Redis Configuration
205+
properties:
206+
serviceName:
207+
type: string
208+
title: Redis 服务名称
209+
x-title-i18n:
210+
en-US: Redis Service Name
211+
description: redis 服务名称,带服务类型的完整 FQDN 名称
212+
x-description-i18n:
213+
en-US: The complete FQDN name of the Redis service, including the service type
214+
servicePort:
215+
type: integer
216+
title: Redis 服务端口
217+
x-title-i18n:
218+
en-US: Redis Service Port
219+
description: redis 服务端口
220+
x-description-i18n:
221+
en-US: Redis service port
222+
default: 6379
223+
timeout:
224+
type: integer
225+
title: Redis 超时时间
226+
x-title-i18n:
227+
en-US: Redis Timeout
228+
description: 请求 redis 的超时时间,单位为毫秒
229+
x-description-i18n:
230+
en-US: Timeout for requests to Redis, in milliseconds
231+
default: 1000
232+
username:
233+
type: string
234+
title: Redis 用户名
235+
x-title-i18n:
236+
en-US: Redis Username
237+
description: 登陆 redis 的用户名
238+
x-description-i18n:
239+
en-US: Username for logging into Redis
240+
password:
241+
type: string
242+
title: Redis 密码
243+
x-title-i18n:
244+
en-US: Redis Password
245+
description: 登陆 redis 的密码
246+
x-description-i18n:
247+
en-US: Password for logging into Redis
248+
required:
249+
- serviceName
250+
returnResponseTemplate:
251+
type: string
252+
title: 响应模板
253+
x-title-i18n:
254+
en-US: Response Template
255+
description: 返回 HTTP 响应的模版,用 %s 标记需要被 cache value 替换的部分
256+
x-description-i18n:
257+
en-US: Template for returning HTTP response, with %s marking the part to be replaced by cache value
258+
default: '{"id":"from-cache","choices":[%s],"model":"gpt-4o","object":"chat.completion","usage":{"prompt_tokens":0,"completion_tokens":0,"total_tokens":0}}'
259+
returnStreamResponseTemplate:
260+
type: string
261+
title: 流式响应模板
262+
x-title-i18n:
263+
en-US: Stream Response Template
264+
description: 返回流式 HTTP 响应的模版,用 %s 标记需要被 cache value 替换的部分
265+
x-description-i18n:
266+
en-US: Template for returning streaming HTTP response, with %s marking the part to be replaced by cache value
267+
default: 'data:{"id":"from-cache","choices":[{"index":0,"delta":{"role":"assistant","content":"%s"},"finish_reason":"stop"}],"model":"gpt-4o","object":"chat.completion","usage":{"prompt_tokens":0,"completion_tokens":0,"total_tokens":0}}\n\ndata:[DONE]\n\n'
268+
example:
269+
redis:
42270
serviceName: my-redis.dns
43271
timeout: 2000
44272
cacheKeyFrom: "messages.@reverse.0.content"

0 commit comments

Comments
 (0)