Skip to content

Conversation

@nimsara66
Copy link
Contributor

@nimsara66 nimsara66 commented Jan 23, 2026

Purpose

${subject}

Summary by CodeRabbit

  • New Features

    • Added MistralAI as a supported LLM provider template with mappings for prompt, completion, total and remaining tokens, plus request/response model detection.
  • Tests

    • Added comprehensive integration tests for LLM provider template lifecycle: create, retrieve, update, delete, list and validation of out-of-box templates.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

Adds a MistralAI LlmProviderTemplate manifest and a Gherkin-based integration test suite with step implementations for LLM provider template lifecycle operations (create, retrieve, update, delete, list).

Changes

Cohort / File(s) Summary
MistralAI Template Configuration
gateway/gateway-controller/default-llm-provider-templates/mistral-template.yaml
Adds a new Kubernetes LlmProviderTemplate resource named mistralai with mappings for displayName, promptTokens, completionTokens, totalTokens, remainingTokens, requestModel, and responseModel sourced from payload fields and a response header.
LLM Provider Template Integration Tests
gateway/it/features/llm-provider-templates.feature, gateway/it/steps_llm.go, gateway/it/suite_test.go
Adds a Gherkin feature file covering template lifecycle scenarios and step implementations registering create/retrieve/update/delete/list HTTP interactions, JSON assertions (including out-of-box template ID checks), and test suite wiring.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped into the gateway, templates in my paw,
MistralAI mapped tokens, neat as a law,
Gherkin steps hopping, requests on the run,
Replies counted carefully, one by one,
A tiny rabbit cheers — integration well done!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete and contains only a placeholder (${subject}) in the Purpose section with no actual details, making it substantially below the required template standards. Complete the description by filling in all required template sections: Purpose (explain why tests are needed), Goals, Approach, User stories, Documentation, Automation tests details, Security checks, Samples, Related PRs, and Test environment.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: implementing integration tests for provider templates, which is directly reflected in the added test files and feature definitions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@gateway/it/steps_llm.go`:
- Around line 57-115: The step handler for `the response should contain
oob-templates` currently returns nil on an empty body and uses a hard-coded
expectedCount; change it to treat an empty body as an error (return a
descriptive fmt.Errorf if body == "" or len(body) == 0) and remove the fixed
numeric check against response.Count — instead derive expected count from the
expectedIDs slice (e.g., compare response.Count to len(expectedIDs>) or drop the
Count assertion entirely and only assert that every ID in expectedIDs appears in
response.Templates). Update references in the function (`body`,
`response.Count`, `expectedIDs`) accordingly so the test fails on missing
response and is not brittle when new templates are added.
🧹 Nitpick comments (2)
gateway/gateway-controller/default-llm-provider-templates/mistral-template.yaml (1)

19-42: Template mapping looks good; remember to rebuild gateway images.

Line 19-42: The token/model mappings look consistent; please rebuild gateway images before running the suite (cd gateway && make build-local). As per coding guidelines, please rebuild after gateway-controller changes.

gateway/it/steps_llm.go (1)

53-55: URL‑encode filter parameters to avoid malformed queries.

Line 53-55: Building the query string via concatenation will break if filterKey or filterValue contains reserved characters. Please confirm whether the API expects encoded parameters; if yes, use url.Values (or QueryEscape) to build the query safely.

♻️ Proposed refactor
@@
-import (
-	"encoding/json"
-	"fmt"
-
-	"github.com/cucumber/godog"
-	"github.com/wso2/api-platform/gateway/it/steps"
-)
+import (
+	"encoding/json"
+	"fmt"
+	"net/url"
+
+	"github.com/cucumber/godog"
+	"github.com/wso2/api-platform/gateway/it/steps"
+)
@@
-	ctx.Step(`^I list LLM provider templates with filter "([^"]*)" as "([^"]*)"$`, func(filterKey, filterValue string) error {
-		return httpSteps.SendGETToService("gateway-controller", "/llm-provider-templates?"+filterKey+"="+filterValue)
-	})
+	ctx.Step(`^I list LLM provider templates with filter "([^"]*)" as "([^"]*)"$`, func(filterKey, filterValue string) error {
+		q := url.Values{}
+		q.Set(filterKey, filterValue)
+		return httpSteps.SendGETToService("gateway-controller", "/llm-provider-templates?"+q.Encode())
+	})

@Krishanx92 Krishanx92 merged commit 4f7009d into wso2:main Jan 23, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants