From cbf35ee5fe95929c0bac3ae58efbc4c7b0925e70 Mon Sep 17 00:00:00 2001 From: Thenujan-Nagaratnam Date: Tue, 21 May 2024 19:01:33 +0530 Subject: [PATCH 1/4] add ai related apoeration with apictl --- .../ai-related-operations-with-apictl.md | 165 ++++++++++++++++++ en/mkdocs.yml | 5 +- 2 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 en/docs/install-and-setup/setup/api-controller/ai-related-operations-with-apictl.md diff --git a/en/docs/install-and-setup/setup/api-controller/ai-related-operations-with-apictl.md b/en/docs/install-and-setup/setup/api-controller/ai-related-operations-with-apictl.md new file mode 100644 index 0000000000..fa5d765078 --- /dev/null +++ b/en/docs/install-and-setup/setup/api-controller/ai-related-operations-with-apictl.md @@ -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 command below to delete and upload APIs and API Products + + +### Set token as a config variable + +Set the Token (Which is generated for AI features) as a config. + + - **Command** + + ```bash + apictl set --ai-token "" + ``` + +### 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 "" + ``` + + ```bash + apictl ai delete artifacts --token "" -e "" + ``` + + ```bash + apictl ai delete artifacts --token "" --endpoint "" -e "" + ``` + + !!! 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 "" + ``` + + ```bash + apictl ai upload apis -e "" --all + ``` + + ```bash + apictl ai upload apis --token "" --endpoint "" -e "" + ``` + + !!! 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 "" + ``` + + ```bash + apictl ai upload api-products -e "" --all + ``` + + ```bash + apictl ai upload api-products --token "" --endpoint "" -e "" + ``` + + !!! 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. diff --git a/en/mkdocs.yml b/en/mkdocs.yml index 11cb9f2745..ff912be448 100644 --- a/en/mkdocs.yml +++ b/en/mkdocs.yml @@ -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 @@ -1961,6 +1962,6 @@ extra: version: 1.2.0-1 git_tag: v1.2.0.1 site_version: 4.3.0 - # base_path: http://localhost:8000/en/next/ - base_path: https://apim.docs.wso2.com/en/4.3.0 + base_path: http://localhost:8000/en/next/ + # base_path: https://apim.docs.wso2.com/en/4.3.0 envoy_path: https://www.envoyproxy.io/docs/envoy/v1.24.1 From ca15fe507d2819fdfb832c8b4073c4e22fc9f9c9 Mon Sep 17 00:00:00 2001 From: Thenujan-Nagaratnam Date: Tue, 21 May 2024 19:01:38 +0530 Subject: [PATCH 2/4] add ai related apoeration with apictl --- .../setup/api-controller/ai-related-operations-with-apictl.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/docs/install-and-setup/setup/api-controller/ai-related-operations-with-apictl.md b/en/docs/install-and-setup/setup/api-controller/ai-related-operations-with-apictl.md index fa5d765078..a007910bab 100644 --- a/en/docs/install-and-setup/setup/api-controller/ai-related-operations-with-apictl.md +++ b/en/docs/install-and-setup/setup/api-controller/ai-related-operations-with-apictl.md @@ -8,7 +8,7 @@ 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 command below to delete and upload APIs and API Products +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 From b2ca626bbb2154e0e0f91f297b527a850ff91003 Mon Sep 17 00:00:00 2001 From: Thenujan-Nagaratnam Date: Tue, 21 May 2024 19:03:42 +0530 Subject: [PATCH 3/4] change base path --- en/mkdocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/en/mkdocs.yml b/en/mkdocs.yml index ff912be448..bc371bd0a3 100644 --- a/en/mkdocs.yml +++ b/en/mkdocs.yml @@ -1962,6 +1962,6 @@ extra: version: 1.2.0-1 git_tag: v1.2.0.1 site_version: 4.3.0 - base_path: http://localhost:8000/en/next/ - # base_path: https://apim.docs.wso2.com/en/4.3.0 + # base_path: http://localhost:8000/en/next/ + base_path: https://apim.docs.wso2.com/en/4.3.0 envoy_path: https://www.envoyproxy.io/docs/envoy/v1.24.1 From d8bb7f3027622a1ac0534c3707e263dabde05538 Mon Sep 17 00:00:00 2001 From: Thenujan-Nagaratnam Date: Tue, 21 May 2024 21:04:29 +0530 Subject: [PATCH 4/4] add FAQ --- .../discover-apis/marketplace-assistant.md | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/en/docs/consume/discover-apis/marketplace-assistant.md b/en/docs/consume/discover-apis/marketplace-assistant.md index ede71e26ed..63fe471660 100644 --- a/en/docs/consume/discover-apis/marketplace-assistant.md +++ b/en/docs/consume/discover-apis/marketplace-assistant.md @@ -53,6 +53,12 @@ To enable the Marketplace Assistant and populate the vector database, the API Ma 2. Restart the API Manager. +## Step 4 (optional) - Sync vector database with your current APIs and API Products + +To ensure that the Marketplace Assistant is aware of all published APIs and to update the vector database with the current APIs, you have to upload all APIs and API Products. + +For more information, see [AI Related Operations with apictl]({{base_path}}/install-and-setup/setup/api-controller/ai-related-operations-with-apictl/) + ## Step 4 - Engage with the Marketplace Assistant Now that your environment is configured, you're ready to interact with the Marketplace Assistant. Utilize its capabilities to chat with your APIs and receive tailored recommendations. @@ -60,3 +66,81 @@ Now that your environment is configured, you're ready to interact with the Marke ## What's Next? Explore the features and functionalities of the Marketplace Assistant to streamline your API management experience further. + +## FAQ + +### Why is this an experimental feature? + +The Marketplace Assistant is labeled as an experimental feature because it represents innovative technology that is still under development. AI technology is rapidly evolving with significant enhancements in large language models and the introduction of increasingly efficient chips, and we are integrating the latest advancements to enhance our capabilities. Rolling out new features as experimental underscores our commitment to innovation, and as we continue to refine them, we are focused on enhancing their performance and reliability based on user input and ongoing development efforts. + +### What are the usage limits? + +During the trial period, users are subject to the following usage limits: + +- Access to up to 1000 APIs to the vectorDB. +- Limited chat functionality based on the number of tokens used by the language model. + +### Why did I lose my chat history after I logged out? + +Your chat history will be lost after logging out or after a period of inactivity of 1 hour, as per the design of the application. For security and privacy reasons ensure that your conversations are not accessible to other users. Additionally, you have the option to reset your chat history to address any potential privacy concerns. + +### Why does the chat not have the context of the initial interactions? + +The language model operates by considering only the last 5 interactions to respond. Therefore, if your conversation extends beyond 5 interactions, the model may not retain the earlier parts of the chat + +### Why can't I list a large number of APIs as recommendations? + +This is because the assistant is designed to identify the most suitable APIs rather than listing a large number of options. To enhance the recommendation process, we limit the number of APIs provided to the language model as context. This ensures that the assistant suggests more relevant APIs instead of overwhelming the user with every possible option. + +### I'm receiving the message "I am not aware of such API" despite the API being listed on the developer portal. + +There are a few potential reasons for this + +#### Assistant uses only public APIs to provide answers. + +- The marketplace assistant is only using public APIs to answer questions. If there is an API, not a public API, the assistant wouldn't be aware of it. + +#### You may have configured the marketplace assistant after publishing those APIs. + +- APIs are only published to the vector database if the Al features are enabled and the token is configured. If you published the API before configuring the assistant, it might not be in the database, and the assistant wouldn't be aware of it. Re-publishing the API and trying again could resolve this. If you have numerous APIs, there's an option to upload them using the WSO2 API Controller + +#### If you've published the API and are still receiving the above response, there could be two reasons: + +- The API details may have failed to upload to the vector database due to reasons like network issues. +- The language model may not be responding correctly. Even if the APL is in the database, there's a chance the language model can't understand and answer properly. Trying different prompts may help clarify the issue. + +### I am getting this error response: `Apologies for the inconvenience. It appears that the token limit has been exceeded` + +This message indicates that the request you made has exceeded the allowed token limit usage. During the trial period, token usage is limited, You have the option to upgrade your subscription plan to access Marketplace Assistant without interruption. + +### I am getting this error response: Apologies for the inconvenience. `It appears that your token is invalid or expired. Please provide a valid token or upgrade your subscription plan ` + +This message suggests that your on-prem key is not valid or it is expired. You can request an extended trial period or you can upgrade your subscription plan so that you can seamlessly use Marketplace Assistant + +### I am getting this error response: Apologies for the inconvenience. `It seems that something went wrong with the Marketplace Assistant. Please try again later ` + +This message signifies that an unexpected error has occurred. It could be due to various reasons such as server issues, network problems, etc. Kindly reach out to the administrator for assistance in resolving the problem, + +### What type of questions I can ask from Marketplace Assistant: + +You can ask the Marketplace Assistant various questions related to APIs and their functionalities. Some examples include: + +- Searching for specific APIs by name or category. +- Requesting recommendations for APIs based on specific use cases or requirements. +- Inquiring about API, endpoints, or usage guidelines. +- Comparing two APIs with their usage and functionalities. + +For instance, you can ask questions like: + +- I am trying to develop an application where ``. What are APIs you can recommend for me to use? +- What are the APIs you know about ``? +- What are the differences between `` and ``. + +Feel free to ask any questions related to APIs or the functionality of APIs, and the assistant will do its best to provide helpful responses, +if you encounter any issues or have further questions, go to the Issues tab of this GitHub repo [API Manager](https://github.com/wso2/api-manager/issues) and click the New issue button to file a bug report or ask questions. + +### This error message is prompted in the terminal when I use the apictl to upload my APIs: `context deadline exceeded (Client.Timeout exceeded while awaiting headers)`. + +The dafault HTTP request timeout for apictl is 10s. Due to network connnectivity or some other issues, the uploading might exceed this limit. If you encounter this issue you can simply set the timeout to a higher value. + +you can modify the `main_config.yaml` file, which you can find in the `APICTL_CONFIG_DIR` and increase the `http_request_timeout` value (Note that the value should be given in milli seconds, e.g: `http_request_timeout: 20000`).