From 9ea2410388116b0beffa17feeed2415cb3670ebe Mon Sep 17 00:00:00 2001 From: Se7en Date: Wed, 26 Feb 2025 20:47:37 +0800 Subject: [PATCH] feat: update ai-token-ratelimit documentation by removing ai-statistics plugin (#1767) --- .../extensions/ai-token-ratelimit/README.md | 27 +++++++++---------- .../ai-token-ratelimit/README_EN.md | 27 +++++++++---------- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/plugins/wasm-go/extensions/ai-token-ratelimit/README.md b/plugins/wasm-go/extensions/ai-token-ratelimit/README.md index 7b0b290cb..c3c0c2334 100644 --- a/plugins/wasm-go/extensions/ai-token-ratelimit/README.md +++ b/plugins/wasm-go/extensions/ai-token-ratelimit/README.md @@ -258,24 +258,12 @@ spec: '*': "qwen-turbo" ingress: - qwen - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-proxy:v1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-proxy:1.0.0 phase: UNSPECIFIED_PHASE priority: 100 --- apiVersion: extensions.higress.io/v1alpha1 kind: WasmPlugin -metadata: - name: ai-statistics - namespace: higress-system -spec: - defaultConfig: - enable: true - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-token-statistics:v1.0.0 - phase: UNSPECIFIED_PHASE - priority: 200 ---- -apiVersion: extensions.higress.io/v1alpha1 -kind: WasmPlugin metadata: name: ai-token-ratelimit namespace: higress-system @@ -294,7 +282,7 @@ spec: # service_name: redis.default.svc.cluster.local service_name: redis.dns service_port: 6379 - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-token-ratelimit:v1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-token-ratelimit:1.0.0 phase: UNSPECIFIED_PHASE priority: 600 ``` @@ -370,10 +358,19 @@ spec: pathType: Prefix ``` +转发 higress-gateway 的流量到本地,方便进行测试。 + +```bash +kubectl port-forward svc/higress-gateway -n higress-system 18000:80 +``` + 触发限流效果如下: ```bash -curl "http://qwen-test.com:18000/v1/chat/completions?apikey=123456" -H "Content-Type: application/json" -d '{ +curl "http://localhost:18000/v1/chat/completions?apikey=123456" \ +-H "Host: qwen-test.com" \ +-H "Content-Type: application/json" \ +-d '{ "model": "gpt-3", "messages": [ { diff --git a/plugins/wasm-go/extensions/ai-token-ratelimit/README_EN.md b/plugins/wasm-go/extensions/ai-token-ratelimit/README_EN.md index 768433c05..cf502198e 100644 --- a/plugins/wasm-go/extensions/ai-token-ratelimit/README_EN.md +++ b/plugins/wasm-go/extensions/ai-token-ratelimit/README_EN.md @@ -234,24 +234,12 @@ spec: '*': "qwen-turbo" ingress: - qwen - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-proxy:v1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-proxy:1.0.0 phase: UNSPECIFIED_PHASE priority: 100 --- apiVersion: extensions.higress.io/v1alpha1 kind: WasmPlugin -metadata: - name: ai-statistics - namespace: higress-system -spec: - defaultConfig: - enable: true - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-token-statistics:v1.0.0 - phase: UNSPECIFIED_PHASE - priority: 200 ---- -apiVersion: extensions.higress.io/v1alpha1 -kind: WasmPlugin metadata: name: ai-token-ratelimit namespace: higress-system @@ -270,7 +258,7 @@ spec: # service_name: redis.default.svc.cluster.local service_name: redis.dns service_port: 6379 - url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-token-ratelimit:v1.0.0 + url: oci://higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ai-token-ratelimit:1.0.0 phase: UNSPECIFIED_PHASE priority: 600 ``` @@ -347,10 +335,19 @@ spec: pathType: Prefix ``` +Forward the traffic of higress-gateway to the local, making it convenient for testing. + +```bash +kubectl port-forward svc/higress-gateway -n higress-system 18000:80 +``` + The rate limiting effect is triggered as follows: ```bash -curl "http://qwen-test.com:18000/v1/chat/completions?apikey=123456" -H "Content-Type: application/json" -d '{ +curl "http://localhost:18000/v1/chat/completions?apikey=123456" \ +-H "Host: qwen-test.com" \ +-H "Content-Type: application/json" \ +-d '{ "model": "gpt-3", "messages": [ {