-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Code Owners | ||
* @tharikaGitHub @chamilaadhi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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**. | ||
|
||
[]({{base_path}}/assets/img/administer/custom-ai-vendor/add-ai-vendor.png) | ||
|
||
## Step 2 - Provide the AI Vendor Name and Version. | ||
|
||
[]({{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> | ||
|
||
[]({{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. | ||
[]({{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. | ||
[]({{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. | ||
[]({{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. | ||
|
||
[]({{base_path}}/assets/img/administer/custom-ai-vendor/custom-ai-vendor-openapi.png) | ||
|
||
## Step 5 - Configure the Connector Type. | ||
|
||
[]({{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
69
en/docs/administer/ai-vendors/write-ai-vendor-connector.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.