Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gateway/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ gateway:
policies:
- name: add-headers
gomodule: github.com/wso2/gateway-controllers/policies/add-headers@v0
- name: token-based-ratelimit
gomodule: github.com/wso2/gateway-controllers/policies/token-based-ratelimit@v0
- name: advanced-ratelimit
gomodule: github.com/wso2/gateway-controllers/policies/advanced-ratelimit@v0
- name: api-key-auth
Expand Down
35 changes: 35 additions & 0 deletions gateway/examples/test-provider.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: gateway.api-platform.wso2.com/v1alpha1
kind: LlmProvider
metadata:
name: test-openai-provider
spec:
displayName: Test OpenAI Provider
version: v1.0
context: /token-ratelimit
template: test-openai-template
upstream:
url: http://echo-backend:80
auth:
type: api-key
header: Authorization
value: test-api-key
accessControl:
mode: deny_all
exceptions:
- path: /chat/completions
methods: [POST]
policies:
- name: tokenBasedRateLimit
version: v1.0.0
Comment on lines +22 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Policy version mismatch with the actual policy definition.

The example specifies version: v1.0.0 for tokenBasedRateLimit, but the actual policy definition at gateway/policies/token-based-ratelimit/policy-definition.yaml defines version v0.1.0.

🔧 Suggested fix
     - name: tokenBasedRateLimit
-      version: v1.0.0
+      version: v0.1.0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: tokenBasedRateLimit
version: v1.0.0
- name: tokenBasedRateLimit
version: v0.1.0
🤖 Prompt for AI Agents
In `@gateway/examples/test-provider.yaml` around lines 22 - 23, The example's
tokenBasedRateLimit policy version is incorrect; update the version field for
the policy named "tokenBasedRateLimit" in gateway/examples/test-provider.yaml to
match the policy-definition.yaml version (change version: v1.0.0 to version:
v0.1.0) so the example and the actual policy definition
(gateway/policies/token-based-ratelimit/policy-definition.yaml) are consistent.

paths:
- path: /chat/completions
methods: [POST]
params:
promptTokenLimits:
- count: 10
duration: "1m"
totalTokenLimits:
- count: 20
duration: "1m"
algorithm: fixed-window
backend: memory
21 changes: 21 additions & 0 deletions gateway/examples/test-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: gateway.api-platform.wso2.com/v1alpha1
kind: LlmProviderTemplate
metadata:
name: test-openai-template
spec:
displayName: Test OpenAI Template
promptTokens:
location: payload
identifier: $.usage.prompt_tokens
completionTokens:
location: payload
identifier: $.usage.completion_tokens
totalTokens:
location: payload
identifier: $.usage.total_tokens
requestModel:
location: payload
identifier: $.model
responseModel:
location: payload
identifier: $.model
8 changes: 8 additions & 0 deletions gateway/it/docker-compose.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ services:
retries: 10
start_period: 5s

echo-backend-multi-arch:
container_name: it-echo-backend-multi-arch
image: mccutchen/go-httpbin:latest
ports:
- "9082:8080"
networks:
- it-gateway-network

volumes:
controller-data-tests:
driver: local
Expand Down
Loading
Loading