Skip to content

add Model family support #13144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tharindu1st
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Jun 15, 2025

📝 Walkthrough

Walkthrough

This update restructures the handling of LLM provider models across the API management platform. It introduces a new LLMModel object to encapsulate model family/vendor information and associated model names. Database schemas, Java APIs, REST endpoints, and OpenAPI specifications are updated to support model families, including a new modelFamilySupported flag, replacing flat string lists with structured model representations.

Changes

File(s) Change Summary
.../api/APIAdmin.java, .../impl/APIAdminImpl.java Removed the getLLMProviderModels method from the APIAdmin interface and its implementation.
.../api/model/LLMModel.java Added new public class LLMModel to represent a model family/vendor and its models.
.../api/model/LLMProvider.java Changed modelList type from List<String> to List<LLMModel>; added modelFamilySupported boolean field with getter/setter.
.../api/AzureOpenAiLLMProviderService.java, .../api/MistralAiLLMProviderService.java, .../api/OpenAiLLMProviderService.java Refactored model list construction to use LLMModel objects instead of raw strings.
.../impl/dao/ApiMgtDAO.java Updated DAO to handle model families: batch inserts/queries now use LLMModel; added helper methods for structured model handling.
.../impl/dao/constants/SQLConstants.java Modified SQL constants to include MODEL_FAMILY_SUPPORTED and MODEL_FAMILY_NAME in relevant queries.
.../rest.api.admin.v1/impl/LlmProvidersApiServiceImpl.java Refactored REST API to accept and process lists of LLMModelDTO objects, supporting the new model family structure and multipleVendorSupport flag.
.../rest.api.admin.v1/utils/mappings/LLMProviderMappingUtil.java Updated mapping logic to convert LLMProvider model lists to lists of LLMModelDTO objects.
.../rest.api.admin.v1/resources/admin-api.yaml, .../rest.api.common/resources/admin-api.yaml, .../rest.api.common/resources/publisher-api.yaml, .../rest.api.publisher.v1/resources/publisher-api.yaml Updated OpenAPI specs: replaced modelList with models (array of LLMModel), added multipleVendorSupport flag, and defined new LLMModel schema.
.../rest.api.publisher.v1/impl/LLMProviderMappingUtil.java Added method to convert List<LLMModel> to List<LLMModelDTO>.
.../rest.api.publisher.v1/impl/LlmProvidersApiServiceImpl.java Updated model retrieval logic to return structured LLMModelDTO list instead of raw strings.
.../core.feature/resources/sql/*.sql Added MODEL_FAMILY_SUPPORTED column to AM_LLM_PROVIDER and MODEL_FAMILY_NAME to AM_LLM_PROVIDER_MODEL in all supported DB schemas; removed unique constraint on (MODEL_NAME, LLM_PROVIDER_UUID).
.../core.feature/resources/api_definitions/aws_bedrock_api.yaml Added new OpenAPI spec for Amazon Bedrock Converse API, defining endpoints, schemas, and security for conversational AI.
.../core.feature/resources/multi-dc/*/apimgt/tables.sql Removed unique constraint on (MODEL_NAME, LLM_PROVIDER_UUID) from AM_LLM_PROVIDER_MODEL table in multi-DC schemas.
.../rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java Added validation call for API endpoint configuration in addAPIWithGeneratedSwaggerDefinition method.

Sequence Diagram(s)

sequenceDiagram
    participant RESTClient
    participant AdminAPI
    participant LlmProvidersApiServiceImpl
    participant LLMProviderMappingUtil
    participant ApiMgtDAO
    participant Database

    RESTClient->>AdminAPI: POST /llm-providers (with models array, multipleVendorSupport)
    AdminAPI->>LlmProvidersApiServiceImpl: addLLMProvider(...)
    LlmProvidersApiServiceImpl->>LLMProviderMappingUtil: Convert LLMModelDTO list to LLMModel list
    LlmProvidersApiServiceImpl->>ApiMgtDAO: addLLMProvider(..., LLMProvider with List<LLMModel>, modelFamilySupported)
    ApiMgtDAO->>Database: Insert LLMProvider, LLMModel (with MODEL_FAMILY_NAME)
    ApiMgtDAO-->>LlmProvidersApiServiceImpl: LLMProvider (with model families)
    LlmProvidersApiServiceImpl-->>AdminAPI: Response

    RESTClient->>AdminAPI: GET /llm-providers/{id}/models
    AdminAPI->>LlmProvidersApiServiceImpl: getLLMProviderModels(...)
    LlmProvidersApiServiceImpl->>ApiMgtDAO: getLLMProvider(...)
    ApiMgtDAO->>Database: Query LLMProvider and models (grouped by family)
    ApiMgtDAO-->>LlmProvidersApiServiceImpl: LLMProvider (with List<LLMModel>)
    LlmProvidersApiServiceImpl->>LLMProviderMappingUtil: Convert List<LLMModel> to List<LLMModelDTO>
    LlmProvidersApiServiceImpl-->>AdminAPI: List<LLMModelDTO>
Loading
sequenceDiagram
    participant RESTClient
    participant PublisherAPI
    participant LlmProvidersApiServiceImpl
    participant ApiMgtDAO
    participant Database
    participant LLMProviderMappingUtil

    RESTClient->>PublisherAPI: GET /llm-providers/{id}/models
    PublisherAPI->>LlmProvidersApiServiceImpl: getLLMProviderModels(...)
    LlmProvidersApiServiceImpl->>ApiMgtDAO: getLLMProvider(...)
    ApiMgtDAO->>Database: Query LLMProvider and models (with families)
    ApiMgtDAO-->>LlmProvidersApiServiceImpl: LLMProvider (List<LLMModel>)
    LlmProvidersApiServiceImpl->>LLMProviderMappingUtil: fromLLMModelToLLMModelDTO(List<LLMModel>)
    LlmProvidersApiServiceImpl-->>PublisherAPI: List<LLMModelDTO>
Loading

Suggested reviewers

  • tgtshanika
  • chamilaadhi
  • npamudika
  • Arshardh
  • AnuGayan

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.38.1)
components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java
components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java
✨ 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends LLM provider support by introducing model families (vendor grouping) and a flag for multiple-vendor support.

  • Introduces a new LLMModel object to represent vendor and its model values.
  • Updates request/response DTOs, OpenAPI specs, and SQL schema/DAO logic to handle model families and the multipleVendorSupport flag.
  • Adjusts admin API service and mapping utilities to populate and persist the new structures.

Reviewed Changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated no comments.

Show a summary per file
File Description
components/.../LLMModelDTO.java Adds DTO for vendor+values grouping
publisher-api.yaml, admin-api.yaml Updates schema to reference new LLMModel and adds multipleVendorSupport flag
LLMProviderMappingUtil.java Maps internal LLMModel to LLMModelDTO
LlmProvidersApiServiceImpl.java Handles incoming DTOs, builds LLMProvider with families and flag
ApiMgtDAO.java, SQLConstants.java Persists and retrieves model families in DB; adds new SQL columns and methods
APIAdminImpl.java Removes legacy model-list API and delegates via DAO
OpenAiLLMProviderService.java, MistralAiLLMProviderService.java, AzureOpenAiLLMProviderService.java Initializes default LLMModel lists
Comments suppressed due to low confidence (4)

components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/LlmProvidersApiServiceImpl.java:150

  • Consider adding or updating unit tests to verify the new multipleVendorSupport flag and model-family mapping logic in buildLLMProvider, ensuring both single- and multi-vendor setups work as expected.
provider.setModelList(llmModels);

components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/utils/mappings/LLMProviderMappingUtil.java:73

  • Missing import for java.util.stream.Collectors; add import java.util.stream.Collectors; so .collect(Collectors.toList()) compiles successfully.
.collect(Collectors.toList()));

components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/LlmProvidersApiServiceImpl.java:238

  • The multipleVendorSupport parameter passed into updateLLMProvider is never used when building the updated provider. Update buildUpdatedLLMProvider signature to accept this flag and call provider.setModelFamilySupported(multipleVendorSupport) accordingly.
buildUpdatedLLMProvider(retrievedProvider, llmProviderId, description, configurations,

components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java:15382

  • The null-check is inverted: models.get(familyName) returns null on first encounter, so the else branch (llmModel.getValues().add(...)) will NPE. Swap the condition to if (llmModel == null) { ... } else { ... }.
if (llmModel != null) {

Copy link

@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: 17

🔭 Outside diff range comments (2)
components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml (1)

12774-12885: 🛠️ Refactor suggestion

Add required fields and quote example for clarity.

The new LLMModel schema should explicitly declare which properties are mandatory and ensure the vendor example is treated as a string literal. Consider applying this diff:

  LLMModel:
    title: LLM Model
    type: object
+   required:
+     - values
+     - vendor
    properties:
      values:
        type: array
        items:
          type: string
          example: "gpt-4o"
      vendor:
        type: string
-       example: OpenAI
+       example: "OpenAI"

Optionally, add description fields to clarify usage.

components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/LlmProvidersApiServiceImpl.java (1)

285-315: 🛠️ Refactor suggestion

Updating clears existing models when models param is absent

When modelList == null, an empty list is set, wiping all previously stored models unintentionally.

-List<LLMModel> llmModels = new ArrayList<>();
-if (modelList != null) {
-    ...
-}
-provider.setModelList(llmModels);
+if (modelList != null) {
+    provider.setModelList(modelList.stream()
+            .map(dto -> new LLMModel(dto.getVendor(), dto.getValues()))
+            .collect(Collectors.toList()));
+} else {
+    provider.setModelList(retrievedProvider.getModelList());
+}
🧹 Nitpick comments (33)
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/db2.sql (2)

3343-3343: Use consistent data type length for boolean flags
The new MODEL_FAMILY_SUPPORTED column is defined as VARCHAR(10), while the existing BUILT_IN_SUPPORT uses VARCHAR(5) to store 'true'/'false'. Consider aligning them (e.g., VARCHAR(5)) or switching to a CHAR(1) flag with a check constraint ('0'/'1') for stricter boolean enforcement.


3363-3363: Evaluate indexing and nullability for model family name
The added MODEL_FAMILY_NAME is nullable and lacks an index. If you frequently query or filter by this column, adding an index will improve performance. Also, when MODEL_FAMILY_SUPPORTED is true, you might enforce MODEL_FAMILY_NAME as NOT NULL to ensure data consistency.

features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/api_definitions/aws_bedrock_api.yaml (6)

1-14: Suggest defining a global security requirement

Adding a root-level security block ensures every path defaults to requiring the API key, reducing the risk of missing auth on future operations.

Apply this diff:

 openapi: 3.0.3
 info:
   title: Amazon Bedrock Converse API
+security:
+  - api_key: []
 version: "1.0.0"
🧰 Tools
🪛 Checkov (3.2.334)

[HIGH] 1-181: Ensure that the global security field has rules defined

(CKV_OPENAPI_4)


16-23: Group the /converse operation with tags

For better organization in generated docs, consider adding:

tags:
  - Bedrock

immediately under the operation’s metadata.


43-50: Group the /converse-stream operation with tags

Similarly, add:

tags:
  - Bedrock

so the streaming endpoint appears under the same section in your API UI.


85-90: Enforce a maximum size on the messages array

Bound the messages list to prevent excessively large payloads. For example:

       messages:
         type: array
+        maxItems: 100
         description: List of conversation messages including prior turns.
🧰 Tools
🪛 Checkov (3.2.334)

[MEDIUM] 85-90: Ensure that arrays have a maximum number of items

(CKV_OPENAPI_21)


106-111: Enforce a maximum size on additionalModelResponseFieldPaths

Prevent unbounded field lists with:

       additionalModelResponseFieldPaths:
         type: array
+        maxItems: 50
         items:
           type: string

180-180: Add a trailing newline

Ensure the file ends with a newline to satisfy YAML linting requirements.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 180-180: no new line character at the end of file

(new-line-at-end-of-file)

features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/h2.sql (1)

2553-2553: Enforce nullability or default for model family name
MODEL_FAMILY_NAME is nullable, but if MODEL_FAMILY_SUPPORTED is true the field should be populated. Consider adding a NOT NULL constraint or a CHECK that ties MODEL_FAMILY_NAME presence to MODEL_FAMILY_SUPPORTED = TRUE, or provide a sensible default.

features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_rac.sql (2)

3652-3652: Ensure data type length and default consistency
The new MODEL_FAMILY_SUPPORTED column is declared as VARCHAR(10) with a default of 'false', whereas the existing BUILT_IN_SUPPORT flag uses VARCHAR(5). For consistency and to limit storage, consider reducing the length to VARCHAR(5) and/or introducing a CHECK constraint to restrict values to 'true' or 'false'.


3670-3670: Validate nullability and indexing for model family
You’ve made MODEL_FAMILY_NAME nullable, which is fine generally, but if MODEL_FAMILY_SUPPORTED = 'true' this column may become mandatory. Confirm the intended behavior and consider a conditional NOT NULL constraint or application-level validation. Also, if you’ll frequently filter by MODEL_FAMILY_NAME, think about adding an index or extending an existing unique constraint.

features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mssql.sql (1)

2851-2851: Review uniqueness semantics for AM_LLM_PROVIDER_MODEL
The existing unique constraint UNIQUE (MODEL_NAME, LLM_PROVIDER_UUID) omits MODEL_FAMILY_NAME, which may permit duplicate model names across different families under the same provider. If model names must be unique within each family, extend the constraint accordingly.

-    UNIQUE (MODEL_NAME, LLM_PROVIDER_UUID),
+    UNIQUE (MODEL_NAME, MODEL_FAMILY_NAME, LLM_PROVIDER_UUID),
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle.sql (2)

3937-3937: Enforce valid boolean values and verify cross-dialect updates.
Add a CHECK constraint to restrict MODEL_FAMILY_SUPPORTED to 'true' or 'false', and ensure the same column is added in your MySQL/PostgreSQL scripts.

Proposed DDL:

ALTER TABLE AM_LLM_PROVIDER
  ADD CONSTRAINT CHK_AM_LLM_PROVIDER_MODEL_FAMILY_SUPPORTED
    CHECK (MODEL_FAMILY_SUPPORTED IN ('true', 'false'));

Verification script:

#!/bin/bash
# Confirm all SQL dialect files include the new column
rg --files-with-matches "CREATE TABLE.*AM_LLM_PROVIDER" -t sql | while read file; do
  grep -q "MODEL_FAMILY_SUPPORTED" "$file" || echo "Missing MODEL_FAMILY_SUPPORTED in $file"
done

3958-3958: Consider indexing MODEL_FAMILY_NAME for query performance.
If your application filters or groups by MODEL_FAMILY_NAME frequently, an index will improve lookup speed.

Example index:

CREATE INDEX IDX_AM_LLM_PROVIDER_MODEL_FAMILY_NAME
  ON AM_LLM_PROVIDER_MODEL(MODEL_FAMILY_NAME);
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/postgresql.sql (1)

2937-2937: Enforce non-null MODEL_FAMILY_NAME when families are supported
If modelFamilySupported is TRUE, each model must carry a family name. Consider adding a CHECK constraint or marking MODEL_FAMILY_NAME as NOT NULL (with an appropriate default) to prevent orphaned entries.

features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql.sql (1)

2579-2579: Missing index for the new MODEL_FAMILY_NAME column

MODEL_FAMILY_NAME will likely be used in lookup queries when fetching models per family. Consider adding an index (or extending the existing unique index) to prevent full-table scans once the table grows.

CREATE INDEX IDX_LLM_PROVIDER_MODEL_FAMILY
  ON AM_LLM_PROVIDER_MODEL (MODEL_FAMILY_NAME);
components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/OpenAiLLMProviderService.java (2)

21-24: Unused wildcard import avoided – good, but remember code-style ordering

Adding java.util.Arrays and LLMModel imports is correct. Ensure your IDE keeps the project’s import-order rules to avoid future PR noise.


95-99: Set modelFamilySupported explicitly for clarity

You migrated to LLMModel, but the new modelFamilySupported flag on LLMProvider is left to its default value. Being explicit improves readability and protects against constructor-default changes:

 llmProvider.setModelList(modelList);
+// OpenAI ships a single family, hence set to false explicitly
+llmProvider.setModelFamilySupported(false);
components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/MistralAiLLMProviderService.java (1)

95-99: Mirror the explicit flag setting here as well

For consistency with other providers and to document intent:

 llmProvider.setModelList(modelList);
+llmProvider.setModelFamilySupported(false);
components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/AzureOpenAiLLMProviderService.java (1)

96-100: Immutable vs mutable nested list

Arrays.asList(...) returns a fixed-size list. If later code attempts to add/remove models to this values list, you’ll hit UnsupportedOperationException.
If mutability is desired, wrap with new ArrayList<>(Arrays.asList(...)).

components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/LLMModel.java (1)

7-14: Add serialVersionUID and basic value object helpers

LLMModel is Serializable but lacks an explicit serialVersionUID, risking deserialization issues across builds.
Also consider overriding equals, hashCode, and toString (or use Lombok) so the object behaves predictably in collections/logs.

 public class LLMModel implements Serializable {
+    private static final long serialVersionUID = 1L;
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_23c.sql (2)

3938-3938: Use BOOLEAN Type for MODEL_FAMILY_SUPPORTED for Consistency
The new MODEL_FAMILY_SUPPORTED column is defined as VARCHAR(10) with 'false'/'true' values, while existing feature flags use the native BOOLEAN type. Switching this to BOOLEAN DEFAULT FALSE will align with other flags and simplify downstream logic.

Please also verify that equivalent changes are applied to the MySQL/Postgres migration scripts.


3959-3959: Consider Constraint on Optional MODEL_FAMILY_NAME
Currently MODEL_FAMILY_NAME is nullable; however, when MODEL_FAMILY_SUPPORTED is enabled, a missing family name may violate business rules. Consider adding a NOT NULL or a check constraint (e.g. enforce MODEL_FAMILY_NAME IS NOT NULL when supported) to maintain data integrity.

components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/LLMProviderMappingUtil.java (1)

96-105: Method name & null-safety can be tightened

  1. The method handles lists, so a clearer name (e.g., fromLLMModelListToDTOList) would improve readability.
  2. Prefer Collections.emptyList() over new ArrayList<>() for the null-input fast path.
  3. Guard against null elements inside modelList to avoid NPEs:
    .filter(Objects::nonNull)
  4. model.getValues() could be null; consider defaulting to Collections.emptyList().

Example diff:

-public static List<LLMModelDTO> fromLLMModelToLLMModelDTO(List<LLMModel> modelList) {
-    if (modelList == null) {
-        return new ArrayList<>();
-    }
-    return modelList.stream()
-            .map(model -> {
-                return new LLMModelDTO().vendor(model.getModelVendor()).values(model.getValues());
-            })
-            .collect(Collectors.toList());
+public static List<LLMModelDTO> fromLLMModelListToDTOList(List<LLMModel> modelList) {
+    if (modelList == null) {
+        return Collections.emptyList();
+    }
+    return modelList.stream()
+            .filter(Objects::nonNull)
+            .map(model -> new LLMModelDTO()
+                    .vendor(model.getModelVendor())
+                    .values(model.getValues() != null ? model.getValues() : Collections.emptyList()))
+            .collect(Collectors.toList());
 }
components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java (2)

2804-2806: Include model family support in provider lookup by name/version
The GET_LLM_PROVIDER_BY_NAME_AND_VERSION_SQL was updated to select MODEL_FAMILY_SUPPORTED. Good. Consider prefixing with the table alias (e.g., PROVIDER.MODEL_FAMILY_SUPPORTED) for consistency and to avoid ambiguity in complex joins.


2819-2819: Retrieve model family name in provider models query
GET_LLM_PROVIDER_MODELS_SQL selects both MODEL_NAME and MODEL_FAMILY_NAME. This aligns with the new LLMModel structure. For predictable ordering, consider adding an ORDER BY MODEL_FAMILY_NAME, MODEL_NAME.

components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/resources/publisher-api.yaml (1)

12774-12785: Augment LLMModel schema with metadata.

To improve clarity and validation:

  • Add a required array (values, vendor) to enforce mandatory fields.
  • Include description for the component and each property.
  • Consider uniqueItems: true on values if duplicates aren’t allowed.
  • Quote the vendor example ("OpenAI") for YAML consistency.
components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/admin-api.yaml (1)

5407-5417: Enhance LLMModel schema with field descriptions
The LLMModel definition is correct, but adding description entries for values and vendor will improve clarity in generated docs:

values:
  type: array
  items:
    type: string
  description: List of supported model names (e.g., "gpt-4o").
vendor:
  type: string
  description: Name of the model vendor (e.g., "OpenAI").
components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/resources/admin-api.yaml (3)

4242-4242: Fix grammatical error in label creation description.

The description "Label object that should to be added" has an incorrect "should to be". Change it to "Label object to be added."


5402-5406: Require model list parameter.

The models array in LLMProviderRequest should likely be mandatory when multipleVendorSupport is true. Add "models" to the required list in the schema or provide guidance on its necessity.


5442-5452: Make models required in response.

In LLMProviderResponse, the models array should be listed in the required section to guarantee clients always receive model information. Consider adding:

LLMProviderResponse:
  required:
    - models
  properties:
    models: ...
components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/LlmProvidersApiServiceImpl.java (2)

67-68: Javadoc now stale – parameter description mismatches actual type

@param models still says “Comma separated list of models” but the signature was migrated to List<LLMModelDTO>.
Update the comment to avoid misleading API consumers.


128-151: Minor: redundant temporary llmModels allocation

llmModels is only populated when modelList != null; otherwise the empty list is assigned.
You can skip the extra variable and directly set Collections.emptyList() for clarity:

-List<LLMModel> llmModels = new ArrayList<>();
-if (modelList != null) {
-    for (LLMModelDTO modelDTO : modelList) {
-        llmModels.add(new LLMModel(modelDTO.getVendor(), modelDTO.getValues()));
-    }
-}
-provider.setModelList(llmModels);
+if (modelList != null) {
+    provider.setModelList(
+        modelList.stream()
+                 .map(dto -> new LLMModel(dto.getVendor(), dto.getValues()))
+                 .collect(Collectors.toList()));
+} else {
+    provider.setModelList(Collections.emptyList());
+}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 092bb5c and 21d0f58.

⛔ Files ignored due to path filters (8)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/LlmProvidersApi.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/LlmProvidersApiService.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/dto/LLMModelDTO.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/dto/LLMProviderRequestDTO.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/dto/LLMProviderResponseDTO.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/dto/LLMModelDTO.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/LlmProvidersApi.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/LlmProvidersApiService.java is excluded by !**/gen/**
📒 Files selected for processing (27)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIAdmin.java (0 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/AzureOpenAiLLMProviderService.java (3 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/MistralAiLLMProviderService.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/OpenAiLLMProviderService.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/LLMModel.java (1 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/LLMProvider.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIAdminImpl.java (0 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java (10 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/LlmProvidersApiServiceImpl.java (8 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/utils/mappings/LLMProviderMappingUtil.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/resources/admin-api.yaml (5 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/admin-api.yaml (5 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/LLMProviderMappingUtil.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/LlmProvidersApiServiceImpl.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/resources/publisher-api.yaml (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/api_definitions/aws_bedrock_api.yaml (1 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/db2.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/h2.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mssql.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql.sql (1 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql_cluster.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_23c.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_rac.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/postgresql.sql (2 hunks)
💤 Files with no reviewable changes (2)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIAdmin.java
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIAdminImpl.java
🧰 Additional context used
🧬 Code Graph Analysis (2)
components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/LLMProviderMappingUtil.java (3)
components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/LLMModel.java (1)
  • LLMModel (7-34)
components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/LLMProvider.java (1)
  • LLMProvider (30-137)
components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/dto/LLMModelDTO.java (1)
  • LLMModelDTO (23-102)
components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/LlmProvidersApiServiceImpl.java (2)
components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/LLMModel.java (1)
  • LLMModel (7-34)
components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/dto/LLMModelDTO.java (1)
  • LLMModelDTO (23-102)
🪛 Checkov (3.2.334)
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/api_definitions/aws_bedrock_api.yaml

[HIGH] 1-181: Ensure that the global security field has rules defined

(CKV_OPENAPI_4)


[MEDIUM] 85-90: Ensure that arrays have a maximum number of items

(CKV_OPENAPI_21)

🪛 YAMLlint (1.37.1)
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/api_definitions/aws_bedrock_api.yaml

[error] 180-180: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-product (1, group1)
  • GitHub Check: build-product (4, group4)
  • GitHub Check: run-benchmark-test
  • GitHub Check: build-product (3, group3)
  • GitHub Check: build-carbon
  • GitHub Check: build-product (2, group2)
🔇 Additional comments (13)
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql.sql (1)

2571-2571: Boolean flag stored as VARCHAR – verify type & default compatibility

MODEL_FAMILY_SUPPORTED is declared as VARCHAR(10) NOT NULL DEFAULT 'false'.
Storing booleans in a text column can be error-prone and wastes space. MySQL provides TINYINT(1) or ENUM('true','false'), which are semantically clearer and avoid unexpected casing issues.

-MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
+MODEL_FAMILY_SUPPORTED TINYINT(1) NOT NULL DEFAULT 0,

If you keep the current definition, remember to quote the default value correctly for every RDBMS flavour and update the DAO layer to map it to a boolean.

components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/MistralAiLLMProviderService.java (1)

21-24: Imports look good

Necessary imports for Arrays and LLMModel were added correctly.

components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml (1)

9314-9317: Approve the schema reference update but verify consistency across endpoints.

Switching from plain strings to a $ref of LLMModel correctly aligns with the new LLMModel definition. Please ensure that:

  • All other endpoints (e.g., Admin API) referencing model lists are updated similarly.
  • Example payloads and response examples in this spec are adjusted to show the new object shape.
components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/AzureOpenAiLLMProviderService.java (1)

96-100: Remember to flag provider-level “model family supported” capability

LLMProvider now carries a modelFamilySupported boolean. This built-in provider clearly supports families (single vendor entry with multiple models) but the flag isn’t set, so downstream UI/DAO logic may treat it as flat-model.

 llmProvider.setModelList(modelList);
+llmProvider.setModelFamilySupported(true);

Please verify the actual setter name in LLMProvider.

components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java (2)

2800-2801: Select provider model family support flag
The GET_LLM_PROVIDER_SQL now correctly retrieves the new MODEL_FAMILY_SUPPORTED column for LLM providers. Ensure the DAO mapping and LLMProvider model include this field.
Please verify that the corresponding ResultSetExtractor or RowMapper has been updated to map this new column.


2816-2816: Add model family name to model insert
The INSERT_LLM_PROVIDER_MODELS_SQL now persists MODEL_FAMILY_NAME alongside MODEL_NAME. Make sure the DAO method binds parameters in the order (modelName, modelFamilyName, providerUuid).
Double-check that any existing tests for model insertion are updated to include the new parameter.

components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/utils/mappings/LLMProviderMappingUtil.java (1)

20-20: Import aligns with new DTO usage – all good.
No further action needed.

components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/resources/publisher-api.yaml (1)

9315-9317: Reference new LLMModel object for response items.

You’ve correctly updated the endpoint to return an array of LLMModel objects instead of plain strings, aligning the OpenAPI spec with the new domain model.

components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/admin-api.yaml (3)

5387-5393: Verify mapping of multipleVendorSupport to backend field
The new multipleVendorSupport flag in LLMProviderRequest should correspond to the modelFamilySupported boolean in your domain model and DAO layer. Ensure the mapping util and API service correctly translate between these names.


5401-5404: Confirm renaming of modelList to models in request schema
You’ve introduced models as an array of LLMModel in the request. Please verify that all references to the old modelList property have been removed and that code generators or DTO mappers have been updated accordingly.


5449-5452: Confirm renaming of modelList to models in response schema
Similar to the request, ensure the old modelList field is fully removed from LLMProviderResponse and that serialization/deserialization logic aligns with this new models array.

components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/resources/admin-api.yaml (1)

4260-4260: Confirm conflict response addition.

Adding the 409 Conflict response is appropriate when a label already exists. Ensure the client handles this status correctly.

components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/LlmProvidersApiServiceImpl.java (1)

295-296: modelFamilySupported cannot be changed via update

You copy the old value (retrievedProvider.isModelFamilySupported()) without considering the new multipleVendorSupport request param.
Extend the method signature and logic so clients can toggle this flag.

@@ -2532,6 +2532,7 @@ CREATE TABLE IF NOT EXISTS AM_LLM_PROVIDER (
DESCRIPTION VARCHAR(1023),
CONFIGURATIONS BLOB NOT NULL,
API_DEFINITION LONGBLOB NOT NULL,
MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use a consistent data type for boolean flags
Currently MODEL_FAMILY_SUPPORTED is defined as VARCHAR(10) with default 'false'. For consistency with the existing BUILT_IN_SUPPORT column (which uses VARCHAR(5)) and H2’s native boolean support, consider one of the following refactors:

Option A: Switch to a Boolean type

-    MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
+    MODEL_FAMILY_SUPPORTED BOOLEAN NOT NULL DEFAULT FALSE,

Option B: Align string lengths

-    MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
+    MODEL_FAMILY_SUPPORTED VARCHAR(5) NOT NULL DEFAULT 'false',

Ensure your Java entity mappings are updated accordingly.

📝 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
MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
MODEL_FAMILY_SUPPORTED BOOLEAN NOT NULL DEFAULT FALSE,
🤖 Prompt for AI Agents
In
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/h2.sql
at line 2535, the MODEL_FAMILY_SUPPORTED column is defined as VARCHAR(10) with
default 'false', which is inconsistent with the BUILT_IN_SUPPORT column using
VARCHAR(5) and H2's boolean support. To fix this, either change
MODEL_FAMILY_SUPPORTED to a BOOLEAN type with a default of FALSE or adjust its
VARCHAR length to 5 to match BUILT_IN_SUPPORT. Also, update the corresponding
Java entity mappings to reflect this data type change.

@@ -2828,6 +2828,7 @@ CREATE TABLE AM_LLM_PROVIDER (
DESCRIPTION VARCHAR(1023),
CONFIGURATIONS VARBINARY(MAX) NOT NULL,
API_DEFINITION VARBINARY(MAX) NOT NULL,
MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use BIT type for MODEL_FAMILY_SUPPORTED
Consistency: other boolean flags in this schema use BIT (or CHAR(1)) rather than a VARCHAR(10). Switch to a BIT NOT NULL DEFAULT 0 for cleaner storage and indexing.

-    MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
+    MODEL_FAMILY_SUPPORTED BIT NOT NULL DEFAULT 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
MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
MODEL_FAMILY_SUPPORTED BIT NOT NULL DEFAULT 0,
🤖 Prompt for AI Agents
In
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mssql.sql
at line 2831, change the column type of MODEL_FAMILY_SUPPORTED from VARCHAR(10)
to BIT, and update the default value from 'false' to 0. This aligns with the
schema's convention for boolean flags, improving storage efficiency and
indexing.

Comment on lines 2739 to 2741
MODEL_NAME VARCHAR(255) NOT NULL,
MODEL_FAMILY_NAME VARCHAR(255) NULL,
LLM_PROVIDER_UUID VARCHAR(255) NOT NULL,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Missing migration and type consistency for model family name
Similar to above, new MODEL_FAMILY_NAME in AM_LLM_PROVIDER_MODEL won’t be applied on existing schemas. You must supply an ALTER TABLE AM_LLM_PROVIDER_MODEL ADD COLUMN MODEL_FAMILY_NAME VARCHAR(255) migration. Optionally, specify a default or enforce non-null when MODEL_FAMILY_SUPPORTED is true.

Shall I prepare the corresponding ALTER TABLE statement?

🤖 Prompt for AI Agents
In
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql_cluster.sql
around lines 2739 to 2741, the new column MODEL_FAMILY_NAME is added to the
AM_LLM_PROVIDER_MODEL table but there is no corresponding migration to update
existing schemas. To fix this, create an ALTER TABLE migration statement that
adds the MODEL_FAMILY_NAME column with type VARCHAR(255) to the
AM_LLM_PROVIDER_MODEL table. Optionally, set a default value or add a NOT NULL
constraint when MODEL_FAMILY_SUPPORTED is true to maintain type consistency.

@@ -2719,6 +2719,7 @@ CREATE TABLE IF NOT EXISTS AM_LLM_PROVIDER (
DESCRIPTION VARCHAR(1023),
CONFIGURATIONS BLOB NOT NULL,
API_DEFINITION LONGBLOB NOT NULL,
MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Existing installs won’t pick up the new column
Using CREATE TABLE IF NOT EXISTS means that for an existing AM_LLM_PROVIDER table the new MODEL_FAMILY_SUPPORTED column will never be added. You need a migration ALTER TABLE script to add this column.
Additionally, for consistency with the existing BUILT_IN_SUPPORT VARCHAR(5) flag, consider using VARCHAR(5) (or better yet BOOLEAN/TINYINT(1)) instead of VARCHAR(10).

Do you want help drafting the ALTER TABLE AM_LLM_PROVIDER ADD COLUMN MODEL_FAMILY_SUPPORTED ... migration snippet?

🤖 Prompt for AI Agents
In
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql_cluster.sql
at line 2722, the new column MODEL_FAMILY_SUPPORTED is added only in the CREATE
TABLE statement, which won't affect existing tables. To fix this, create a
separate ALTER TABLE migration script that adds the MODEL_FAMILY_SUPPORTED
column to the existing AM_LLM_PROVIDER table. Also, change the column type from
VARCHAR(10) to VARCHAR(5) or preferably BOOLEAN/TINYINT(1) to be consistent with
the BUILT_IN_SUPPORT flag. If needed, draft the ALTER TABLE statement
accordingly.

@@ -2913,6 +2913,7 @@ CREATE TABLE IF NOT EXISTS AM_LLM_PROVIDER (
DESCRIPTION VARCHAR(1023),
CONFIGURATIONS BYTEA NOT NULL,
API_DEFINITION BYTEA NOT NULL,
MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Switch MODEL_FAMILY_SUPPORTED to BOOLEAN and backfill existing rows
Using VARCHAR(10) for a boolean‐style flag can lead to invalid values and wastes storage. Replace it with PostgreSQL’s native BOOLEAN DEFAULT FALSE and include a migration backfill, for example:

ALTER TABLE AM_LLM_PROVIDER
  ALTER COLUMN MODEL_FAMILY_SUPPORTED TYPE BOOLEAN USING (MODEL_FAMILY_SUPPORTED::BOOLEAN),
  ALTER COLUMN MODEL_FAMILY_SUPPORTED SET DEFAULT FALSE;

UPDATE AM_LLM_PROVIDER SET MODEL_FAMILY_SUPPORTED = FALSE;

I’d like to confirm where and how MODEL_FAMILY_SUPPORTED is used across the repo before recommending the change. Let’s locate all references:


🏁 Script executed:

#!/bin/bash
set -e
rg -n "MODEL_FAMILY_SUPPORTED"

Length of output: 2379


Switch MODEL_FAMILY_SUPPORTED to BOOLEAN everywhere and update DAO parsing

We should convert this flag from VARCHAR(10) to native BOOLEAN in all dialect scripts and adjust the Java DAO to read it correctly:

• In each SQL script under features/apimgt/.../sql/ (mssql.sql, postgresql.sql, oracle.sql, oracle_23c.sql, oracle_rac.sql, mysql.sql, mysql_cluster.sql, h2.sql, db2.sql):

-    MODEL_FAMILY_SUPPORTED VARCHAR(10) NOT NULL DEFAULT 'false',
+    MODEL_FAMILY_SUPPORTED BOOLEAN     NOT NULL DEFAULT FALSE,

And add a migration for existing tables, e.g. for Postgres:

ALTER TABLE AM_LLM_PROVIDER
  ALTER COLUMN MODEL_FAMILY_SUPPORTED TYPE BOOLEAN USING (MODEL_FAMILY_SUPPORTED::BOOLEAN),
  ALTER COLUMN MODEL_FAMILY_SUPPORTED SET DEFAULT FALSE;

UPDATE AM_LLM_PROVIDER SET MODEL_FAMILY_SUPPORTED = FALSE;

(Repeat equivalent ALTER/UPDATE for each dialect.)

• In components/apimgt/.../SQLConstants.java: no change to constant strings, but note that the column is now boolean.

• In components/apimgt/.../ApiMgtDAO.java: replace

Boolean.parseBoolean(providerResultSet.getString("MODEL_FAMILY_SUPPORTED"))

with

providerResultSet.getBoolean("MODEL_FAMILY_SUPPORTED")

in both occurrences to avoid parsing “t”/“f” or driver‐specific boolean literals.

This ensures type safety, eliminates invalid values, saves space, and keeps the DAO in sync.

🤖 Prompt for AI Agents
In
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/postgresql.sql
at line 2916, change the MODEL_FAMILY_SUPPORTED column from VARCHAR(10) to
BOOLEAN with DEFAULT FALSE by altering the column type using a cast and setting
the default. Add an UPDATE statement to backfill existing rows with FALSE.
Repeat equivalent ALTER and UPDATE statements in all other SQL dialect scripts
under features/apimgt/.../sql/. Then, in the Java DAO (ApiMgtDAO.java), replace
all occurrences of
Boolean.parseBoolean(providerResultSet.getString("MODEL_FAMILY_SUPPORTED")) with
providerResultSet.getBoolean("MODEL_FAMILY_SUPPORTED") to correctly handle the
boolean type. No changes are needed in SQLConstants.java.

Comment on lines 215 to 226
* @param multipleVendorSupport Whether the provider supports multiple vendors (unused in logic).
* @param configurations The configurations of the provider.
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Docstring & parameter named but still “unused” – leads to API drift

The Javadoc admits multipleVendorSupport is unused in the update path.
Updating the provider should allow toggling this flag; otherwise the REST contract is misleading.

🤖 Prompt for AI Agents
In
components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/LlmProvidersApiServiceImpl.java
around lines 215-216, the parameter multipleVendorSupport is documented but not
used in the update logic, causing API drift. To fix this, incorporate logic to
update the multipleVendorSupport flag in the provider update method so that
changes to this flag are reflected, ensuring the REST API contract matches the
implementation.

Comment on lines 225 to 240
public Response updateLLMProvider(String llmProviderId, String name, String apiVersion,
String description, String configurations, InputStream apiDefinitionInputStream,
Attachment apiDefinitionDetail, String modelList, MessageContext messageContext)
String description, Boolean multipleVendorSupport, String configurations,
InputStream apiDefinitionInputStream,
Attachment apiDefinitionDetail, List<LLMModelDTO> models,
MessageContext messageContext)
throws APIManagementException {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

multipleVendorSupport ignored in update flow

updateLLMProvider(..) receives the Boolean but never propagates it to buildUpdatedLLMProvider(..).
Result: clients cannot change the flag once the provider is created.

- buildUpdatedLLMProvider(retrievedProvider, llmProviderId, description,
-                         configurations, apiDefinitionInputStream, models);
+ buildUpdatedLLMProvider(retrievedProvider, llmProviderId, description,
+                         configurations, apiDefinitionInputStream, models,
+                         multipleVendorSupport);

and extend the helper method accordingly.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest.api.admin.v1.impl/LlmProvidersApiServiceImpl.java
around lines 225 to 230, the multipleVendorSupport parameter is received in
updateLLMProvider but not passed to buildUpdatedLLMProvider, preventing updates
to this flag. Modify the updateLLMProvider method to pass multipleVendorSupport
to buildUpdatedLLMProvider and update the helper method signature and
implementation to accept and handle this parameter accordingly.

Comment on lines 15205 to 15218
private void addLLMModels(Connection connection, LLMProvider llmProvider) throws SQLException {
try (PreparedStatement prepStmtInsertModels = connection.prepareStatement(
SQLConstants.INSERT_LLM_PROVIDER_MODELS_SQL)) {
// Insert LLM provider model
for (LLMModel model : llmProvider.getModelList()) {
for (String value : model.getValues()) {
prepStmtInsertModels.setString(1, value);
prepStmtInsertModels.setString(2, model.getModelVendor());
prepStmtInsertModels.setString(3, llmProvider.getId());
prepStmtInsertModels.addBatch();
}
}
prepStmtInsertModels.executeBatch();
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Null-safety + batch insert robustness

llmProvider.getModelList() or model.getValues() may legally be null/empty when a provider is first created.
Guard the loops and skip the batch when there is nothing to persist to avoid NullPointerException.

-for (LLMModel model : llmProvider.getModelList()) {
-    for (String value : model.getValues()) {
+if (llmProvider.getModelList() != null) {
+    for (LLMModel model : llmProvider.getModelList()) {
+        if (model.getValues() == null) {
+            continue;
+        }
+        for (String value : model.getValues()) {
             ...
         }
     }
 }
📝 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
private void addLLMModels(Connection connection, LLMProvider llmProvider) throws SQLException {
try (PreparedStatement prepStmtInsertModels = connection.prepareStatement(
SQLConstants.INSERT_LLM_PROVIDER_MODELS_SQL)) {
// Insert LLM provider model
for (LLMModel model : llmProvider.getModelList()) {
for (String value : model.getValues()) {
prepStmtInsertModels.setString(1, value);
prepStmtInsertModels.setString(2, model.getModelVendor());
prepStmtInsertModels.setString(3, llmProvider.getId());
prepStmtInsertModels.addBatch();
}
}
prepStmtInsertModels.executeBatch();
}
if (llmProvider.getModelList() != null) {
for (LLMModel model : llmProvider.getModelList()) {
if (model.getValues() == null) {
continue;
}
for (String value : model.getValues()) {
// …
}
}
}
🤖 Prompt for AI Agents
In
components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java
around lines 15205 to 15218, add null checks before iterating over
llmProvider.getModelList() and model.getValues(). If either is null or empty,
skip the batch insert logic to prevent NullPointerException. This involves
checking for null or empty collections before the loops and returning early or
continuing as appropriate.

@tharindu1st tharindu1st force-pushed the model-family-support branch from 21d0f58 to 4a0a021 Compare June 23, 2025 11:17
Copy link

@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

🧹 Nitpick comments (2)
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/api_definitions/aws_bedrock_api.yaml (2)

85-90: Define maximum items for array properties
Prevent excessively large requests by adding a maxItems constraint to arrays such as messages and additionalModelResponseFieldPaths.

Example diff for messages:

     messages:
       type: array
       description: List of conversation messages including prior turns.
+      maxItems: 100
       items:
         $ref: '#/components/schemas/Message'

Mirror this for additionalModelResponseFieldPaths.


180-180: Ensure newline at end of file
YAMLLint flags missing newline at EOF.

Add a newline character after the last line.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21d0f58 and 4a0a021.

⛔ Files ignored due to path filters (8)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/LlmProvidersApi.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/LlmProvidersApiService.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/dto/LLMModelDTO.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/dto/LLMProviderRequestDTO.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/admin/v1/dto/LLMProviderResponseDTO.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/dto/LLMModelDTO.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/LlmProvidersApi.java is excluded by !**/gen/**
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/LlmProvidersApiService.java is excluded by !**/gen/**
📒 Files selected for processing (32)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIAdmin.java (0 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/AzureOpenAiLLMProviderService.java (3 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/MistralAiLLMProviderService.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/OpenAiLLMProviderService.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/LLMModel.java (1 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/LLMProvider.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIAdminImpl.java (1 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java (10 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/LlmProvidersApiServiceImpl.java (10 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/utils/mappings/LLMProviderMappingUtil.java (3 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/resources/admin-api.yaml (6 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/admin-api.yaml (6 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java (1 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/LLMProviderMappingUtil.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/LlmProvidersApiServiceImpl.java (2 hunks)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/resources/publisher-api.yaml (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/api_definitions/aws_bedrock_api.yaml (1 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/multi-dc/OGG/oracle/apimgt/tables.sql (0 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/multi-dc/OGG/oracle/apimgt/tables_23c.sql (0 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/multi-dc/Postgresql/apimgt/tables.sql (0 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/multi-dc/SQLServer/mssql/apimgt/tables.sql (0 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/db2.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/h2.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mssql.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql.sql (1 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql_cluster.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_23c.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_rac.sql (2 hunks)
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/postgresql.sql (2 hunks)
💤 Files with no reviewable changes (5)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIAdmin.java
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/multi-dc/OGG/oracle/apimgt/tables.sql
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/multi-dc/Postgresql/apimgt/tables.sql
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/multi-dc/OGG/oracle/apimgt/tables_23c.sql
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/multi-dc/SQLServer/mssql/apimgt/tables.sql
✅ Files skipped from review due to trivial changes (2)
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/PublisherCommonUtils.java
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_23c.sql
🚧 Files skipped from review as they are similar to previous changes (24)
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/OpenAiLLMProviderService.java
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/AzureOpenAiLLMProviderService.java
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/LlmProvidersApiServiceImpl.java
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/MistralAiLLMProviderService.java
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/LLMModel.java
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/LLMProviderMappingUtil.java
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/resources/publisher-api.yaml
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/utils/mappings/LLMProviderMappingUtil.java
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/h2.sql
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle.sql
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/oracle_rac.sql
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mssql.sql
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql_cluster.sql
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/mysql.sql
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/db2.sql
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/constants/SQLConstants.java
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIAdminImpl.java
  • components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/LLMProvider.java
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/LlmProvidersApiServiceImpl.java
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/admin-api.yaml
  • features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/sql/postgresql.sql
  • components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/resources/admin-api.yaml
🧰 Additional context used
🪛 Checkov (3.2.334)
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/api_definitions/aws_bedrock_api.yaml

[HIGH] 1-181: Ensure that the global security field has rules defined

(CKV_OPENAPI_4)


[MEDIUM] 85-90: Ensure that arrays have a maximum number of items

(CKV_OPENAPI_21)

🪛 YAMLlint (1.37.1)
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/api_definitions/aws_bedrock_api.yaml

[error] 180-180: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (11)
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/api_definitions/aws_bedrock_api.yaml (11)

1-7: OpenAPI header and info section is valid
API version, title, and description align with Amazon Bedrock’s conversational API.


8-14: Server variable configuration is correct
The region variable defaults to us-east-1 with an appropriate description.


15-41: Operation-level security is applied
Each endpoint correctly includes security: - api_key: [].


42-67: Streaming endpoint definition looks good
/converse-stream is defined with consistent request/response structure and security.


68-74: Security scheme definition looks correct
The API key scheme under components.securitySchemes is properly declared.


75-103: ConverseRequest schema is comprehensive
Covers session context, messages, inference config, and optional fields as intended.


115-128: Message schema is well-defined
Required role and content fields use clear enums and descriptions.


129-140: InferenceConfig schema covers key parameters
maxTokens, temperature, and topP are correctly typed and described.


142-162: ConverseResponse schema aligns with expected output
Includes sessionId, output, and ancillary info like metrics and usage.


163-169: ConverseStreamResponse schema is appropriate
Defines a stream array of StreamEvent for chunked responses.


172-180: StreamEvent schema is valid
Captures eventType and data fields for streaming events.

Comment on lines +1 to +7
openapi: 3.0.3
info:
title: Amazon Bedrock Converse API
version: "1.0.0"
description: |
OpenAPI specification for Amazon Bedrock's Converse and ConverseStream operations.

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add a global security definition to enforce API key usage
Defining security at the root reduces repetition and ensures all operations are secured.

Apply this diff:

 openapi: 3.0.3
 info:
   title: Amazon Bedrock Converse API
   version: "1.0.0"
   description: |
     OpenAPI specification for Amazon Bedrock's Converse and ConverseStream operations.
+security:
+  - api_key: []
🧰 Tools
🪛 Checkov (3.2.334)

[HIGH] 1-181: Ensure that the global security field has rules defined

(CKV_OPENAPI_4)

🤖 Prompt for AI Agents
In
features/apimgt/org.wso2.carbon.apimgt.core.feature/src/main/resources/api_definitions/aws_bedrock_api.yaml
at the top (lines 1 to 7), add a global security definition to enforce API key
usage by defining a security scheme under components and applying a root-level
security requirement. This will ensure all API operations require the API key
without repeating security details in each operation.

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.

1 participant