Skip to content
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

Add AI related operations with apictl #7989

Open
wants to merge 4 commits into
base: 4.3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# AI Related operations with apictl

To ensure that the Marketplace Assistant is fully informed about all published APIs and API Products, it is essential to update the vector database with the current APIs.
**WSO2 API Controller (apictl)** allows you to update the vector Database with the current APIs.

First you have to download and intialize the apictl.

1. Make sure that the WSO2 API-M is started and that the corresponding version of apictl is set up.
For more information, see [Download and Initialize the apictl]({{base_path}}/install-and-setup/setup/api-controller/getting-started-with-wso2-api-controller/#download-and-initialize-the-apictl).
2. Log in to the WSO2 API-M in the environment by following the instructions in [Login to an Environment]({{base_path}}/install-and-setup/setup/api-controller/getting-started-with-wso2-api-controller/#login-to-an-environment).
3. Run the corresponding apictl commands below to delete and upload APIs and API Products from a logged in user's tenant.


### Set token as a config variable

Set the Token (Which is generated for AI features) as a config.

- **Command**

```bash
apictl set --ai-token "<use token that you generated>"
```

### Delete APIs and API Products from vector database.

Run the following command to delete all the APIs and API Products from the vector database from the currently logged-in user's tenant within a specified environment.

- **Command**

```bash
apictl ai delete artifacts -e "<environment>"
```

```bash
apictl ai delete artifacts --token "<use token that you generated>" -e "<environment>"
```

```bash
apictl ai delete artifacts --token "<use token that you generated>" --endpoint "<endpoint of ai service>" -e "<environment>"
```

!!! info
**Flags:**

- Required :
`--environment` or `-e` : Environment to be searched
- Optional :
`--token` : On prem key of AI services
`--endpoint` : Endpoint url of AI services

!!! example
```bash
apictl ai delete artifacts -e dev
```

```bash
apictl ai delete artifacts --token 2fdca1b6-6a28-4aea-add6-77c97033bdb9 artifacts -e dev
```

```bash
apictl ai delete artifacts --token 2fdca1b6-6a28-4aea-add6-77c97033bdb9 artifacts --endpoint https://dev-tools.wso2.com/apim-ai-service -e dev
```
!!! note
- Note that if you have already set the token to the config variable, you dont have to use the --token flag


### Upload APIs to vector database.

Run the following command to upload all the APIs to the vector database from the currently logged-in user's tenant within a specified environment.

- **Command**

```bash
apictl ai upload apis -e "<environment>"
```

```bash
apictl ai upload apis -e "<environment>" --all
```

```bash
apictl ai upload apis --token "<use token that you generated>" --endpoint "<endpoint of ai service>" -e "<environment>"
```

!!! info
**Flags:**

- Required :
`--environment` or `-e` : Environment to be searched
- Optional :
`--token` : On prem key of AI services
`--endpoint` : Endpoint url of AI services
`--all` : Upload both APIs and API Products.

!!! example
```bash
apictl ai upload apis -e dev
```

```bash
apictl ai upload apis -e dev --all
```

```bash
apictl ai upload apis --token 2fdca1b6-6a28-4aea-add6-77c97033bdb9 artifacts -e dev
```

```bash
apictl ai upload apis --token 2fdca1b6-6a28-4aea-add6-77c97033bdb9 artifacts --endpoint https://dev-tools.wso2.com/apim-ai-service -e dev
```
!!! note
- Note that if you have already set the token to the config variable, you dont have to use the --token flag

### Upload API Products to vector database.

Run the following command to upload all the API Products to the vector database from the currently logged-in user's tenant within a specified environment.

- **Command**

```bash
apictl ai upload api-products -e "<environment>"
```

```bash
apictl ai upload api-products -e "<environment>" --all
```

```bash
apictl ai upload api-products --token "<use token that you generated>" --endpoint "<endpoint of ai service>" -e "<environment>"
```

!!! info
**Flags:**

- Required :
`--environment` or `-e` : Environment to be searched
- Optional :
`--token` : On prem key of AI services
`--endpoint` : Endpoint url of AI services
`--all` : Upload both APIs and API Products.

!!! example
```bash
apictl ai upload api-products -e dev
```

```bash
apictl ai upload api-products -e dev --all
```

```bash
apictl ai upload api-products --token 2fdca1b6-6a28-4aea-add6-77c97033bdb9 artifacts -e dev
```

```bash
apictl ai upload api-products --token 2fdca1b6-6a28-4aea-add6-77c97033bdb9 artifacts --endpoint https://dev-tools.wso2.com/apim-ai-service -e dev
```
!!! note
- Note that if you have already set the token to the config variable, you dont have to use the --token flag

This process can be repeated for all tenants.

If you intend to use the same access token across different deployments, you can continue using it without generating a new one each time.

This process ensures that the Marketplace Assistant is up-to-date with all published APIs, enhancing its ability to provide accurate and relevant assistance.
1 change: 1 addition & 0 deletions en/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ nav:
- Migrate Common API Policies to Different Environments: install-and-setup/setup/api-controller/managing-common-api-policies/migrating-common-api-policies-to-different-environments.md
- Encrypt Secrets with apictl: install-and-setup/setup/api-controller/encrypting-secrets-with-ctl.md
- Enable Correlation Logs with apictl: install-and-setup/setup/api-controller/enabling-correlation-logs-with-apictl.md
- AI Related Operations with apictl: install-and-setup/setup/api-controller/ai-related-operations-with-apictl.md
- Advanced Topics:
- Create Custom Users to Perform apictl Operations: install-and-setup/setup/api-controller/advanced-topics/creating-custom-users-to-perform-api-controller-operations.md
- Configure Environment Specific Parameters: install-and-setup/setup/api-controller/advanced-topics/configuring-environment-specific-parameters.md
Expand Down