Skip to content

Commit

Permalink
Merge branch 'master' into apictl-m
Browse files Browse the repository at this point in the history
  • Loading branch information
ashera96 authored Dec 6, 2024
2 parents 38eb56c + f51be97 commit 4139531
Show file tree
Hide file tree
Showing 4,223 changed files with 25,944 additions and 223,344 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code Owners
* @tharikaGitHub @chamilaadhi

31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "🐞 Report a Bug"
description: Create an issue if something does not work as expected.
labels: ["Type/Bug"]
body:
- type: textarea
id: background
attributes:
label: Description
description: Please share a clear and concise description of the problem.
placeholder: Description
- type: textarea
id: steps
attributes:
label: Steps to Reproduce
description: List the steps you followed when you encountered the issue. Provide sample source code to reproduce the issue where applicable.
validations:
required: true
- type: input
id: version
attributes:
label: Version
description: Enter product/component version.
validations:
required: true
- type: textarea
id: environment
attributes:
label: Environment Details (with versions)
description: Mention the environment details (OS, Client, etc.) that the product is running on.
validations:
required: false
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
blank_issues_enabled: false
contact_links:
- name: '📚 Documentation Issue'
about: Request a new article, missing topic, or report an issue if a topic is incorrect in the current documentation.
url: https://github.com/wso2/docs-apim/issues/new/choose
- name: 'General Question'
url: https://stackoverflow.com/questions/tagged/wso2-api-manager
about: "If you have a question then please ask on Stack Overflow using the #wso2-api-manager tag."
Chat with the community to get quick clarifications for your questions.
- name: Chat on help-api-manager Discord Channel
url: https://discord.com/invite/Xa5VubmThw
about: "Chat about anything else with the community."
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/improvement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "🚀 Improvement Request"
description: Suggest an improvement to the product.
labels: ["Type/Improvement"]
body:
- type: textarea
id: limitation
attributes:
label: Current Limitation
description: Describe the the current limitation.
validations:
required: true
- type: textarea
id: suggestion
attributes:
label: Suggested Improvement
description: Describe the the improvement you suggest.
validations:
required: true
- type: input
id: version
attributes:
label: Version
description: Enter component version.
validations:
required: false
50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/question_form.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "🙋 Ask a Question"
description: Ask a question about the product suite.
labels: ["Type/Question"]
body:
- type: textarea
id: description
attributes:
label: Description
description: Describe the question.
validations:
required: true
- type: dropdown
id: component
attributes:
label: Affected Component
description: Select affected component.
options:
- Analytics
- APICTL
- APIM
validations:
required: true
- type: input
id: version
attributes:
label: Version
description: Enter component version.
validations:
required: true
- type: textarea
id: environment
attributes:
label: Environment Details (with versions)
description: Mention the environment details (OS, Client, etc.) that the product is running on.
validations:
required: true
- type: textarea
id: related
attributes:
label: Related Issues
description: Mention if any related issues.
validations:
required: false
- type: input
id: suggested
attributes:
label: Suggested Labels
description: Mention if any suggested labels.
validations:
required: false
3 changes: 0 additions & 3 deletions CODEOWNERS

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ As an open source project, WSO2 API-M welcomes contributions from the community.

If the CLA gets changed for some (unlikely) reason, you will be presented with the new CLA text after sending your first PR after the change.

2. Fork this repository, make your changes, and send in a pull request (PR). Make sure you are contributing to the correct branch (for example, if your change is relevant to WSO2 API-M 3.2.0 documentation, you should commit your changes to the 3.2.0 branch).
2. Fork this repository, make your changes, and send in a pull request (PR). Make sure you are contributing to the correct branch (for example, if your change is relevant to WSO2 API-M 4.4.0 documentation, you should commit your changes to the 4.4.0 branch).

3. Send multiple pull requests to all the relevant branches.

If your change is relevant to the latest API-M release, please send your change to the respective latest API-M release branch and the master branch, which is the upcoming API-M release documentation branch, as well.

For example, if the latest API-M release is 3.2.0, and if your change is relevant to API-M 3.2.0, 3.1.0, and 3.0.0, send PRs to the 3.0.0, 3.1.0, 3.2.0, and the master branches.
For example, if the latest API-M release is 4.4.0, and if your change is relevant to API-M 4.4.0, 4.3.0, and 4.2.0, send PRs to the 4.4.0, 4.3.0, 4.2.0, and the master branches.

Check the issue tracker for open issues that interest you. We look forward to receiving your contributions.

Expand Down
4 changes: 2 additions & 2 deletions en/docs/administer/admin-overview.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Administration Overview

This section covers administration tasks you need to perform in WSO2 API Manager to support the core functions of the API Manager, Micro Integrator, and the Streaming Integrator. These include managing users and roles, configuring and managing a multi-tenant environment, registering key managers, advanced configuration, etc.
This section covers administration tasks you need to perform in WSO2 API Manager. These include managing users and roles, configuring and managing a multi-tenant environment, registering key managers, advanced configuration, etc.

- [Managing Users and Roles]({{base_path}}/administer/managing-users-and-roles/managing-user-stores/introduction-to-userstores)
- [Secondary User Stores]({{base_path}}/administer/managing-users-and-roles/managing-user-stores/introduction-to-userstores)
- [Multitenancy]({{base_path}}/administer/multitenancy/introduction-to-multitenancy)
- [Key Managers]({{base_path}}/administer/key-managers/overview)
- [Advanced Configurations]({{base_path}}/administer/advanced-configurations)
- [Advanced Configurations]({{base_path}}/administer/advanced-configurations)
129 changes: 129 additions & 0 deletions en/docs/administer/ai-vendors/custom-ai-vendor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Configure a Custom AI Vendor

You can integrate **WSO2 API Manager** with custom AI vendors to consume their services via AI APIs. This guide walks you through configuring a custom AI vendor to manage and track AI model interactions efficiently.

## Step 1 - Add a new AI Vendor

Navigate to the **AI Vendors** section in the WSO2 API Manager admin portal sidebar, and select **Add AI Vendor**.

[![Add AI Vendor]({{base_path}}/assets/img/administer/custom-ai-vendor/add-ai-vendor.png)]({{base_path}}/assets/img/administer/custom-ai-vendor/add-ai-vendor.png)

## Step 2 - Provide the AI Vendor Name and Version.

[![Add AI Vendor General Details]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-general-details.png)]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-general-details.png)

## Step 3 - Configure Data Extraction for AI Model and Token Usage.

This step involves configuring the extraction of key information from request/ response flow to support token-based throttling and analytics, including:

<table>
<colgroup>
<col />
<col />
<col />
</colgroup>
<tbody>
<tr>
<th colspan="2">Field</th>
<th>Description</th>
</tr>
<tr>
<td colspan="2">AI Model Name</td>
<td>Name of the AI Model responding to the request</td>
</tr>
<tr>
<td colspan="2">Prompt Token Count</td>
<td>Number of tokens consumed by the request prompt</td>
</tr>
<tr>
<td colspan="2">Completion Token Count</td>
<td>Number of tokens consumed by the AI Model response</td>
</tr>
<tr>
<td colspan="2">Total Token Count</td>
<td>Number of tokens consumed by both request prompt and AI Model response</td>
</tr>
</tbody>
</table>

[![Add AI Vendor General Details]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-general-details-llm-configurations.png)]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-general-details-llm-configurations.png)

1. If the data is in the request payload, specify the appropriate **JSON path** to extract the values.
[![AI Vendor General Details - Payload]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-general-details-llm-configurations-payload.png)]({{base_path}}/assets/img/administer/custom-ai-vendor/ccustom-ai-vendor-general-details-llm-configurations-payload.png)

!!! example "Mistral AI Response Payload"
Below outlines the structure of a sample Mistral AI response payload and provides details on how specific fields can be extracted using JSON paths.

```json
{
"id": "cmpl-e5cc70bb28c444948073e77776eb30ef",
"object": "chat.completion",
"model": "mistral-small-latest",
"usage": {
"prompt_tokens": 16,
"completion_tokens": 34,
"total_tokens": 50
},
"created": 1702256327,
"choices": [
{
"index": 0,
"message": {
"content": "string",
"tool_calls": [
{
"id": "null",
"type": "function",
"function": {
"name": "string",
"arguments": {}
}
}
],
"prefix": false,
"role": "assistant"
},
"finish_reason": "stop"
}
]
}
```

- Extracting model information:
- The `model` field is located at the root level of the response payload.
- **Valid JSON Path**: `$.model`
- Extracting prompt token count:
- The `prompt_tokens` field is nested within the `usage` object.
- **Valid JSON Path**: `$.usage.prompt_tokens`
- Extracting completion token count:
- The `completion_tokens` field is also nested within the `usage` object.
- **Valid JSON Path**: `$.usage.completion_tokens`
- Extracting total token count:
The `total_tokens` field is located within the `usage` object.
- **Valid JSON Path**: `$.usage.total_tokens`

2. If the data is in the request header, provide the header key.
[![AI Vendor General Details - Header]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-general-details-llm-configurations-header.png)]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-general-details-llm-configurations-header.png)

3. If the data is in a query parameter, provide the query parameter identifier.
[![AI Vendor General Details - Query Param]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-general-details-llm-configurations-queryparam.png)]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-general-details-llm-configurations-queryparam.png)

## Step 4 - Upload the API Definition.

Upload the **OpenAPI specification** file provided by the custom AI vendor. This step defines the API endpoints and operations that the vendor offers.

[![AI Vendor API Spec]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-openapi.png)]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-openapi.png)

## Step 5 - Configure the Connector Type.

[![AI Vendor Connector Type]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-connectortype.png)]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-connectortype.png)

<html><div class="admonition note">
<p class="admonition-title">Note</p>
<p>The <a href='https://github.com/wso2/carbon-apimgt/blob/master/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/DefaultLLMProviderService.java'>`default`</a> connector type is a built in connector to extract AI model name, prompt token count, completion token count, total token count from the response.
To write your own connector follow <a href='{{base_path}}/administer/ai-vendors/write-ai-vendor-connector/'>
Write a connector for a Custom AI Vendor.</a></p>
<p>
</div>
</html>

69 changes: 69 additions & 0 deletions en/docs/administer/ai-vendors/write-ai-vendor-connector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Write a Connector for a Custom AI Vendor

When onboarding a custom AI vendor to API Manager, you have the option to either use the built-in <a href='https://github.com/wso2/carbon-apimgt/blob/master/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/DefaultLLMProviderService.java'>`default`</a> connector or write your own custom connector.

This guide provides step-by-step instructions for creating and deploying a custom AI vendor connector in WSO2 API Manager.

## Step 1 - Create a AI Vendor Connector Bundle

1. Set up a Maven project.

You can download a sample Maven project from [here]({{base_path}}/assets/attachments/administer/llm.provider.connector.zip).

However, when manually creating a maven project, you will need to define a class that implements the `LLMProviderService` interface that is responsible handling request/ response payloads specific to AI vendors in the API Manager.

2. Implement `LLMProviderService`.

The following are the methods that the `LLMProviderService` interface uses to carry out various related operations.

<table>
<colgroup>
<col width="30%" />
<col width="70%" />
</colgroup>
<thead>
<tr class="header">
<th><b>Method</b></th>
<th><b>Description</b></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><strong>getResponseMetadata</strong></td>
<td><p>
This method is responsible for extracting metadata from the response, which may be present in the response payload, headers, or query parameters. It takes the response payload and headers as input, along with a list of metadata keys that need to be extracted. The method processes the input data and returns a map containing the extracted metadata. If the extraction fails for any reason, it throws an <code>APIManagementException</code>, ensuring the error is captured and handled appropriately.
</p></td>
</tr>
<tr class="even">
<td><strong>getRequestMetadata</strong></td>
<td><p>
This method is used to extract metadata from the request, similar to how <strong>getResponseMetadata</strong> works for responses. It takes the request payload, headers, and query parameters, along with a list of metadata keys that need to be extracted. The method processes these inputs and returns a map containing the extracted metadata. In case of failure during extraction, it throws an <code>APIManagementException</code>, ensuring the issue is properly managed.
</p></td>
</tr>
<tr class="odd">
<td><strong>getType</strong></td>
<td><p>This method retrieves the connector type for the custom Large Language Model (LLM) provider. It returns a string that corresponds to the connector type configured in the admin portal under the "Connector Type for AI Vendor" section. The string returned by this method ensures that the correct custom LLM provider is used during interactions between the system and the AI vendor.</p></td>
</tr>
<tr class="even">
<td><strong>registerLLMProvider</strong></td>
<td><p>This method handles the registration of a new custom LLM provider. It programmatically onboard's the provider during the startup process. If the LLM provider is being onboarded manually through the admin portal, the method can return null. The method accepts the organization's name and the path to the API definition file associated with the provider, and it returns an instance of <strong>LLMProvider</strong> representing the newly registered provider. If any errors occur during the registration process, the method throws an <strong>APIManagementException</strong>.
</p></td>
</tr>
</tbody>
</table>

3. Build the project.

Once you've implemented the necessary methods, navigate to the `<PROJECT_HOME>` directory and execute the following command.

`mvn clean install`

This will create a custom AI vendor connector JAR.

## Step 2 - Deploy the bundle in the WSO2 API-M Server

1. Stop the API-M server if it is already running.

2. Copy the JAR file that is generated in the `custom.llm.provider` component target directory, and add it in to the `<API-M Server>/repository/components/dropins/` directory.

3. Start the Server
Loading

0 comments on commit 4139531

Please sign in to comment.