Skip to content

Commit

Permalink
feat: update ai-token-ratelimit documentation by removing ai-statisti…
Browse files Browse the repository at this point in the history
…cs plugin (#1767)
  • Loading branch information
cr7258 authored Feb 26, 2025
1 parent 9e1792c commit 9ea2410
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
27 changes: 12 additions & 15 deletions plugins/wasm-go/extensions/ai-token-ratelimit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
Expand Down Expand Up @@ -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": [
{
Expand Down
27 changes: 12 additions & 15 deletions plugins/wasm-go/extensions/ai-token-ratelimit/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
Expand Down Expand Up @@ -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": [
{
Expand Down

0 comments on commit 9ea2410

Please sign in to comment.