From d327c8f5d2242df11d198d2082ceadb719e41507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=AD=20Santos?= <140329135+itzraiss@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:50:28 -0300 Subject: [PATCH] =?UTF-8?q?Updated:=20Azure=20Cognitive=20Search=20Plugin/?= =?UTF-8?q?=20Free=20AI=20APIs=20=F0=9F=94=8E=20(#1230)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update azure_cognitive_search.md * Updated: Azure Cognitive Search Plugin to Azure AI Search Plugin. Update Docs: Azure Cognitive Search Plugin to Azure AI Search Plugin. Updated:.env.example Azure Cognitive Search to Azure AI Search Updated: mkdocs.yml link Updated: SDK Azure 11.3.2 to 12.0.0 * fix:.env AZURE- to AZURE_ * Update azure_ai_search.md * Updated:(api/package.json, package-lock.json): updated for new version the plugin (@azure/search-documents) * fix:Resolved incorrect file name AzureAISearch * fix:.env Azure AI Search * fix:"-" to "_" * Update Docs: Azure AI Search ith an improved tutorial featuring images and easier-to-understand instructions fix: Change name of plugin "Azure Ai Search" to "Azure AI Search" i * Update:Version of REST API versions (Azure AI Search) * Update azure_ai_search.md * Update azure_ai_search.md * Update azure_ai_search.md * fix: docs Azure AI Seach Images were not appearing. * fix:Updated to the new repository with working APIs * Update: Added Compatibility for Previous Environment Variable Names in AzureAISearch Plugin * Update: Added Compatibility for Previous Environment Variable Names in AzureAISearch Plugin * Update: Added Compatibility for Previous Environment Variable Names in AzureAISearch Plugin * Update: Added Compatibility for Previous Environment Variable Names in AzureAISearch Plugin * Update: o AzureAiSearch.js * Atualizar o AzureAISearch.js * Update/fix:EnvironmentVariablesForDeprecation * fix:The file is outdated and needs to be updated. * fix:The file is outdated and needs to be updated. * update: translation portuguese brazilian * Refactor:Improve Readability and Cleanliness of AzureAISearch Class * Update AzureAiSearch.js * Update AzureAISearch.js --- .env.example | 20 +-- api/app/clients/tools/AzureAiSearch.js | 59 ++++++++ api/app/clients/tools/AzureCognitiveSearch.js | 111 -------------- api/app/clients/tools/index.js | 6 +- api/app/clients/tools/manifest.json | 24 +-- .../clients/tools/structured/AzureAISearch.js | 68 +++++++++ .../tools/structured/AzureCognitiveSearch.js | 116 --------------- api/app/clients/tools/util/handleTools.js | 4 +- api/package.json | 2 +- client/src/localization/languages/Br.tsx | 1 + docs/features/plugins/azure_ai_search.md | 139 ++++++++++++++++++ .../plugins/azure_cognitive_search.md | 57 ------- docs/install/free_ai_apis.md | 2 +- mkdocs.yml | 2 +- package-lock.json | 36 ++--- 15 files changed, 315 insertions(+), 332 deletions(-) create mode 100644 api/app/clients/tools/AzureAiSearch.js delete mode 100644 api/app/clients/tools/AzureCognitiveSearch.js create mode 100644 api/app/clients/tools/structured/AzureAISearch.js delete mode 100644 api/app/clients/tools/structured/AzureCognitiveSearch.js create mode 100644 docs/features/plugins/azure_ai_search.md delete mode 100644 docs/features/plugins/azure_cognitive_search.md diff --git a/.env.example b/.env.example index 8c75e431c..e4f235c75 100644 --- a/.env.example +++ b/.env.example @@ -294,17 +294,17 @@ GOOGLE_CSE_ID= # Use "http://127.0.0.1:7860" with local install and "http://host.docker.internal:7860" for docker SD_WEBUI_URL=http://host.docker.internal:7860 -# Azure Cognitive Search -# This plugin supports searching Azure Cognitive Search for answers to your questions. -# See detailed instructions here: https://github.com/danny-avila/LibreChat/blob/main/docs/features/plugins/azure_cognitive_search.md -AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT= -AZURE_COGNITIVE_SEARCH_INDEX_NAME= -AZURE_COGNITIVE_SEARCH_API_KEY= +# Azure AI Search +# This plugin supports searching Azure AI Search for answers to your questions. +# See detailed instructions here: https://github.com/danny-avila/LibreChat/blob/main/docs/features/plugins/azure_ai_search.md +AZURE_AI_SEARCH_SERVICE_ENDPOINT= +AZURE_AI_SEARCH_INDEX_NAME= +AZURE_AI_SEARCH_API_KEY= -AZURE_COGNITIVE_SEARCH_API_VERSION= -AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_QUERY_TYPE= -AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP= -AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_SELECT= +AZURE_AI_SEARCH_API_VERSION= +AZURE_AI_SEARCH_SEARCH_OPTION_QUERY_TYPE= +AZURE_AI_SEARCH_SEARCH_OPTION_TOP= +AZURE_AI_SEARCH_SEARCH_OPTION_SELECT= ########################## # PaLM (Google) Endpoint: diff --git a/api/app/clients/tools/AzureAiSearch.js b/api/app/clients/tools/AzureAiSearch.js new file mode 100644 index 000000000..7a5742b17 --- /dev/null +++ b/api/app/clients/tools/AzureAiSearch.js @@ -0,0 +1,59 @@ +const { Tool } = require('langchain/tools'); +const { SearchClient, AzureKeyCredential } = require('@azure/search-documents'); + +class AzureAISearch extends Tool { + static DEFAULT_API_VERSION = '2023-11-01'; + static DEFAULT_QUERY_TYPE = 'simple'; + static DEFAULT_TOP = 5; + + constructor(fields = {}) { + super(); + this.initializeProperties(fields); + this.initializeClient(); + } + + initializeProperties(fields) { + const getValue = (fieldNames, defaultValue) => { + for (const name of fieldNames) { + const value = fields[name] || process.env[name]; + if (value !== undefined && value !== null) return value; + } + return defaultValue; + }; + + this.serviceEndpoint = getValue(['AZURE_AI_SEARCH_SERVICE_ENDPOINT', 'AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT'], this.getServiceEndpoint()); + this.indexName = getValue(['AZURE_AI_SEARCH_INDEX_NAME', 'AZURE_COGNITIVE_SEARCH_INDEX_NAME'], this.getIndexName()); + this.apiKey = getValue(['AZURE_AI_SEARCH_API_KEY', 'AZURE_COGNITIVE_SEARCH_API_KEY'], this.getApiKey()); + this.apiVersion = getValue(['AZURE_AI_SEARCH_API_VERSION', 'AZURE_COGNITIVE_SEARCH_API_VERSION'], AzureAISearch.DEFAULT_API_VERSION); + this.queryType = getValue(['AZURE_AI_SEARCH_SEARCH_OPTION_QUERY_TYPE', 'AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_QUERY_TYPE'], AzureAISearch.DEFAULT_QUERY_TYPE); + this.top = getValue(['AZURE_AI_SEARCH_SEARCH_OPTION_TOP', 'AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP'], AzureAISearch.DEFAULT_TOP); + this.select = this.getSelect(); + } + + initializeClient() { + this.client = new SearchClient(this.serviceEndpoint, this.indexName, new AzureKeyCredential(this.apiKey), { apiVersion: this.apiVersion }); + } + + name = 'azure-ai-search'; + + description = + 'Use the \'azure-ai-search\' tool to retrieve search results relevant to your input'; + + async _call(query) { + try { + const searchOptions = { + queryType: this.queryType, + top: this.top, + select: this.select + }; + + const searchResults = await this.client.search(query, searchOptions); + return JSON.stringify(searchResults.results.map(result => result.document)); + } catch (error) { + console.error(`Azure AI Search request failed: ${error}`); + return 'There was an error with Azure AI Search.'; + } + } +} + +module.exports = AzureAISearch; diff --git a/api/app/clients/tools/AzureCognitiveSearch.js b/api/app/clients/tools/AzureCognitiveSearch.js deleted file mode 100644 index d7c508c9f..000000000 --- a/api/app/clients/tools/AzureCognitiveSearch.js +++ /dev/null @@ -1,111 +0,0 @@ -const { Tool } = require('langchain/tools'); -const { SearchClient, AzureKeyCredential } = require('@azure/search-documents'); - -class AzureCognitiveSearch extends Tool { - constructor(fields = {}) { - super(); - this.serviceEndpoint = - fields.AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT || this.getServiceEndpoint(); - this.indexName = fields.AZURE_COGNITIVE_SEARCH_INDEX_NAME || this.getIndexName(); - this.apiKey = fields.AZURE_COGNITIVE_SEARCH_API_KEY || this.getApiKey(); - - this.apiVersion = fields.AZURE_COGNITIVE_SEARCH_API_VERSION || this.getApiVersion(); - - this.queryType = fields.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_QUERY_TYPE || this.getQueryType(); - this.top = fields.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP || this.getTop(); - this.select = fields.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_SELECT || this.getSelect(); - - this.client = new SearchClient( - this.serviceEndpoint, - this.indexName, - new AzureKeyCredential(this.apiKey), - { - apiVersion: this.apiVersion, - }, - ); - } - - /** - * The name of the tool. - * @type {string} - */ - name = 'azure-cognitive-search'; - - /** - * A description for the agent to use - * @type {string} - */ - description = - 'Use the \'azure-cognitive-search\' tool to retrieve search results relevant to your input'; - - getServiceEndpoint() { - const serviceEndpoint = process.env.AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT || ''; - if (!serviceEndpoint) { - throw new Error('Missing AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT environment variable.'); - } - return serviceEndpoint; - } - - getIndexName() { - const indexName = process.env.AZURE_COGNITIVE_SEARCH_INDEX_NAME || ''; - if (!indexName) { - throw new Error('Missing AZURE_COGNITIVE_SEARCH_INDEX_NAME environment variable.'); - } - return indexName; - } - - getApiKey() { - const apiKey = process.env.AZURE_COGNITIVE_SEARCH_API_KEY || ''; - if (!apiKey) { - throw new Error('Missing AZURE_COGNITIVE_SEARCH_API_KEY environment variable.'); - } - return apiKey; - } - - getApiVersion() { - return process.env.AZURE_COGNITIVE_SEARCH_API_VERSION || '2020-06-30'; - } - - getQueryType() { - return process.env.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_QUERY_TYPE || 'simple'; - } - - getTop() { - if (process.env.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP) { - return Number(process.env.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP); - } else { - return 5; - } - } - - getSelect() { - if (process.env.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_SELECT) { - return process.env.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_SELECT.split(','); - } else { - return null; - } - } - - async _call(query) { - try { - const searchOption = { - queryType: this.queryType, - top: this.top, - }; - if (this.select) { - searchOption.select = this.select; - } - const searchResults = await this.client.search(query, searchOption); - const resultDocuments = []; - for await (const result of searchResults.results) { - resultDocuments.push(result.document); - } - return JSON.stringify(resultDocuments); - } catch (error) { - console.error(`Azure Cognitive Search request failed: ${error}`); - return 'There was an error with Azure Cognitive Search.'; - } - } -} - -module.exports = AzureCognitiveSearch; diff --git a/api/app/clients/tools/index.js b/api/app/clients/tools/index.js index ce5c7d591..a5e64a2b9 100644 --- a/api/app/clients/tools/index.js +++ b/api/app/clients/tools/index.js @@ -8,8 +8,8 @@ const StableDiffusionAPI = require('./StableDiffusion'); const WolframAlphaAPI = require('./Wolfram'); const StructuredWolfram = require('./structured/Wolfram'); const SelfReflectionTool = require('./SelfReflection'); -const AzureCognitiveSearch = require('./AzureCognitiveSearch'); -const StructuredACS = require('./structured/AzureCognitiveSearch'); +const AzureAiSearch = require('./AzureAiSearch'); +const StructuredACS = require('./structured/AzureAISearch'); const ChatTool = require('./structured/ChatTool'); const E2BTools = require('./structured/E2BTools'); const CodeSherpa = require('./structured/CodeSherpa'); @@ -30,7 +30,7 @@ module.exports = { WolframAlphaAPI, StructuredWolfram, SelfReflectionTool, - AzureCognitiveSearch, + AzureAiSearch, StructuredACS, E2BTools, ChatTool, diff --git a/api/app/clients/tools/manifest.json b/api/app/clients/tools/manifest.json index 84c0a10e6..ac4423c70 100644 --- a/api/app/clients/tools/manifest.json +++ b/api/app/clients/tools/manifest.json @@ -143,25 +143,25 @@ ] }, { - "name": "Azure Cognitive Search", - "pluginKey": "azure-cognitive-search", - "description": "Use Azure Cognitive Search to find information", + "name": "Azure AI Search", + "pluginKey": "azure-ai-search", + "description": "Use Azure AI Search to find information", "icon": "https://i.imgur.com/E7crPze.png", "authConfig": [ { - "authField": "AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT", - "label": "Azur Cognitive Search Endpoint", - "description": "You need to provide your Endpoint for Azure Cognitive Search." + "authField": "AZURE_AI_SEARCH_SERVICE_ENDPOINT", + "label": "Azure AI Search Endpoint", + "description": "You need to provide your Endpoint for Azure AI Search." }, { - "authField": "AZURE_COGNITIVE_SEARCH_INDEX_NAME", - "label": "Azur Cognitive Search Index Name", - "description": "You need to provide your Index Name for Azure Cognitive Search." + "authField": "AZURE_AI_SEARCH_INDEX_NAME", + "label": "Azure AI Search Index Name", + "description": "You need to provide your Index Name for Azure AI Search." }, { - "authField": "AZURE_COGNITIVE_SEARCH_API_KEY", - "label": "Azur Cognitive Search API Key", - "description": "You need to provideq your API Key for Azure Cognitive Search." + "authField": "AZURE_AI_SEARCH_API_KEY", + "label": "Azure AI Search API Key", + "description": "You need to provideq your API Key for Azure AI Search." } ] }, diff --git a/api/app/clients/tools/structured/AzureAISearch.js b/api/app/clients/tools/structured/AzureAISearch.js new file mode 100644 index 000000000..8d22ced0b --- /dev/null +++ b/api/app/clients/tools/structured/AzureAISearch.js @@ -0,0 +1,68 @@ +const { StructuredTool } = require('langchain/tools'); +const { z } = require('zod'); +const { SearchClient, AzureKeyCredential } = require('@azure/search-documents'); + +class AzureAISearch extends StructuredTool { + static DEFAULT_API_VERSION = '2023-11-01'; + static DEFAULT_QUERY_TYPE = 'simple'; + static DEFAULT_TOP = 5; + + constructor(fields = {}) { + super(); + this.initializeProperties(fields); + this.initializeClient(); + this.initializeSchema(); + } + + initializeProperties(fields) { + const getValue = (fieldNames, defaultValue) => { + for (const name of fieldNames) { + const value = fields[name] || process.env[name]; + if (value !== undefined && value !== null) return value; + } + return defaultValue; + }; + + this.serviceEndpoint = getValue(['AZURE_AI_SEARCH_SERVICE_ENDPOINT', 'AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT'], this.getServiceEndpoint()); + this.indexName = getValue(['AZURE_AI_SEARCH_INDEX_NAME', 'AZURE_COGNITIVE_SEARCH_INDEX_NAME'], this.getIndexName()); + this.apiKey = getValue(['AZURE_AI_SEARCH_API_KEY', 'AZURE_COGNITIVE_SEARCH_API_KEY'], this.getApiKey()); + this.apiVersion = getValue(['AZURE_AI_SEARCH_API_VERSION', 'AZURE_COGNITIVE_SEARCH_API_VERSION'], AzureAISearch.DEFAULT_API_VERSION); + this.queryType = getValue(['AZURE_AI_SEARCH_SEARCH_OPTION_QUERY_TYPE', 'AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_QUERY_TYPE'], AzureAISearch.DEFAULT_QUERY_TYPE); + this.top = getValue(['AZURE_AI_SEARCH_SEARCH_OPTION_TOP', 'AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP'], AzureAISearch.DEFAULT_TOP); + this.select = this.getSelect(); + } + + initializeClient() { + this.client = new SearchClient(this.serviceEndpoint, this.indexName, new AzureKeyCredential(this.apiKey), { apiVersion: this.apiVersion }); + } + + initializeSchema() { + this.schema = z.object({ + query: z.string().describe('Search word or phrase to Azure AI Search'), + }); + } + + name = 'azure-ai-search'; + + description = + 'Use the \'azure-ai-search\' tool to retrieve search results relevant to your input'; + + async _call(data) { + const { query } = data; + try { + const searchOptions = { + queryType: this.queryType, + top: this.top, + select: this.select + }; + + const searchResults = await this.client.search(query, searchOptions); + return JSON.stringify(searchResults.results.map(result => result.document)); + } catch (error) { + console.error(`Azure AI Search request failed: ${error}`); + return 'There was an error with Azure AI Search.'; + } + } +} + +module.exports = AzureAISearch; diff --git a/api/app/clients/tools/structured/AzureCognitiveSearch.js b/api/app/clients/tools/structured/AzureCognitiveSearch.js deleted file mode 100644 index a94774cf9..000000000 --- a/api/app/clients/tools/structured/AzureCognitiveSearch.js +++ /dev/null @@ -1,116 +0,0 @@ -const { StructuredTool } = require('langchain/tools'); -const { z } = require('zod'); -const { SearchClient, AzureKeyCredential } = require('@azure/search-documents'); - -class AzureCognitiveSearch extends StructuredTool { - constructor(fields = {}) { - super(); - this.serviceEndpoint = - fields.AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT || this.getServiceEndpoint(); - this.indexName = fields.AZURE_COGNITIVE_SEARCH_INDEX_NAME || this.getIndexName(); - this.apiKey = fields.AZURE_COGNITIVE_SEARCH_API_KEY || this.getApiKey(); - - this.apiVersion = fields.AZURE_COGNITIVE_SEARCH_API_VERSION || this.getApiVersion(); - - this.queryType = fields.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_QUERY_TYPE || this.getQueryType(); - this.top = fields.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP || this.getTop(); - this.select = fields.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_SELECT || this.getSelect(); - - this.client = new SearchClient( - this.serviceEndpoint, - this.indexName, - new AzureKeyCredential(this.apiKey), - { - apiVersion: this.apiVersion, - }, - ); - this.schema = z.object({ - query: z.string().describe('Search word or phrase to Azure Cognitive Search'), - }); - } - - /** - * The name of the tool. - * @type {string} - */ - name = 'azure-cognitive-search'; - - /** - * A description for the agent to use - * @type {string} - */ - description = - 'Use the \'azure-cognitive-search\' tool to retrieve search results relevant to your input'; - - getServiceEndpoint() { - const serviceEndpoint = process.env.AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT || ''; - if (!serviceEndpoint) { - throw new Error('Missing AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT environment variable.'); - } - return serviceEndpoint; - } - - getIndexName() { - const indexName = process.env.AZURE_COGNITIVE_SEARCH_INDEX_NAME || ''; - if (!indexName) { - throw new Error('Missing AZURE_COGNITIVE_SEARCH_INDEX_NAME environment variable.'); - } - return indexName; - } - - getApiKey() { - const apiKey = process.env.AZURE_COGNITIVE_SEARCH_API_KEY || ''; - if (!apiKey) { - throw new Error('Missing AZURE_COGNITIVE_SEARCH_API_KEY environment variable.'); - } - return apiKey; - } - - getApiVersion() { - return process.env.AZURE_COGNITIVE_SEARCH_API_VERSION || '2020-06-30'; - } - - getQueryType() { - return process.env.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_QUERY_TYPE || 'simple'; - } - - getTop() { - if (process.env.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP) { - return Number(process.env.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP); - } else { - return 5; - } - } - - getSelect() { - if (process.env.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_SELECT) { - return process.env.AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_SELECT.split(','); - } else { - return null; - } - } - - async _call(data) { - const { query } = data; - try { - const searchOption = { - queryType: this.queryType, - top: this.top, - }; - if (this.select) { - searchOption.select = this.select; - } - const searchResults = await this.client.search(query, searchOption); - const resultDocuments = []; - for await (const result of searchResults.results) { - resultDocuments.push(result.document); - } - return JSON.stringify(resultDocuments); - } catch (error) { - console.error(`Azure Cognitive Search request failed: ${error}`); - return 'There was an error with Azure Cognitive Search.'; - } - } -} - -module.exports = AzureCognitiveSearch; diff --git a/api/app/clients/tools/util/handleTools.js b/api/app/clients/tools/util/handleTools.js index eb40760b0..e26dc3344 100644 --- a/api/app/clients/tools/util/handleTools.js +++ b/api/app/clients/tools/util/handleTools.js @@ -17,7 +17,7 @@ const { StableDiffusionAPI, DALLE3, StructuredSD, - AzureCognitiveSearch, + AzureAISearch, StructuredACS, E2BTools, CodeSherpa, @@ -101,7 +101,7 @@ const loadTools = async ({ wolfram: functions ? StructuredWolfram : WolframAlphaAPI, 'dall-e': OpenAICreateImage, 'stable-diffusion': functions ? StructuredSD : StableDiffusionAPI, - 'azure-cognitive-search': functions ? StructuredACS : AzureCognitiveSearch, + 'azure-ai-search': functions ? StructuredACS : AzureAISearch, CodeBrew: CodeBrew, }; diff --git a/api/package.json b/api/package.json index 6c34a7ef1..a4b8e1a31 100644 --- a/api/package.json +++ b/api/package.json @@ -28,7 +28,7 @@ "homepage": "https://github.com/danny-avila/LibreChat#readme", "dependencies": { "@anthropic-ai/sdk": "^0.5.4", - "@azure/search-documents": "^11.3.2", + "@azure/search-documents": "^12.0.0", "@keyv/mongo": "^2.1.8", "@keyv/redis": "^2.8.0", "axios": "^1.3.4", diff --git a/client/src/localization/languages/Br.tsx b/client/src/localization/languages/Br.tsx index a2cf673ac..cbd6ce519 100644 --- a/client/src/localization/languages/Br.tsx +++ b/client/src/localization/languages/Br.tsx @@ -226,6 +226,7 @@ export default { com_endpoint_config_key_google_vertex_api: 'API no Google Cloud, depois', com_endpoint_config_key_google_vertex_api_role: 'Certifique-se de clicar em "Criar e Continuar" para dar pelo menos a função de "Usuário do Vertex AI". Por último, crie uma chave JSON para importar aqui.', + com_nav_welcome_message: 'Como eu posso ajudar hoje?', com_nav_auto_scroll: 'Auto-rolar para o mais recente ao abrir', com_nav_plugin_store: 'Loja de plugins', com_nav_plugin_search: 'Pesquisar plugins', diff --git a/docs/features/plugins/azure_ai_search.md b/docs/features/plugins/azure_ai_search.md new file mode 100644 index 000000000..865180c63 --- /dev/null +++ b/docs/features/plugins/azure_ai_search.md @@ -0,0 +1,139 @@ +# Azure AI Search Plugin +Through the plugins endpoint, you can use Azure AI Search for answers to your questions with assistance from GPT. + +## Configurations + +### Required + +To get started, you need to get a Azure AI Search endpoint URL, index name, and a API Key. You can then define these as follows in your `.env` file: + +```env +AZURE_AI_SEARCH_SERVICE_ENDPOINT="..." +AZURE_AI_SEARCH_INDEX_NAME="..." +AZURE_AI_SEARCH_API_KEY="..." +``` +Or you need to get an Azure AI Search endpoint URL, index name, and an API Key. You can define them during the installation of the plugin. + +### AZURE_AI_SEARCH_SERVICE_ENDPOINT + +This is the URL of the search endpoint. It can be obtained from the top page of the search service in the Cognitive Search management console (e.g., `https://example.search.windows.net`). + +### AZURE_AI_SEARCH_INDEX_NAME + +This is the name of the index to be searched (e.g., `hotels-sample-index`). + +### AZURE_AI_SEARCH_API_KEY + +This is the authentication key to use when utilizing the search endpoint. Please issue it from the management console. Use the Value, not the name of the authentication key. + +# Introduction to tutorial + +## Create or log in to your account on Azure Portal + +**1.** Visit [https://azure.microsoft.com/en-us/](https://azure.microsoft.com/en-us/) and click on `Get started` or `Try Azure for Free` to create an account and sign in. + +**2.** Choose pay per use or Azure Free with $200. + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20151647.png?token=GHSAT0AAAAAACJ4TKEINPEOAV3LEPNPBDNCZLEKLAQ) + +## Create the Azure AI Search service + +**1.** Access your control panel. + +**2.** Click on `Create a resource`. + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20151706.png?token=GHSAT0AAAAAACJ4TKEJDXD7E76YLZEV52Z4ZLEKLCQ) + +**3.** Search for `Azure Search` in the bar and press enter. + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20151732.png?token=GHSAT0AAAAAACJ4TKEJ7QZGNSNEOYKRGDIUZLEKLEQ) + +**4.** Now, click on `Create`. + +**5.** Configure the basics settings, create a new or select an existing Resource Group, name the Service Name with a name of your preference, and then select the location. + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20151749.png?token=GHSAT0AAAAAACJ4TKEIPAZQJNYQ7RQLHVZCZLEKLGA) + +**6.** Click on `Change Pricing Tier`. + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20151753.png?token=GHSAT0AAAAAACJ4TKEI6CUJZWIYIMDW2ZOOZLEKLHQ) + +Now select the free option or select your preferred option (may incur charges). + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20151758.png?token=GHSAT0AAAAAACJ4TKEIU3TNDUT33I7NVJ5OZLEKLJQ) + +**7.** Click on `Review + create` and wait for the resource to be created. + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20151810.png?token=GHSAT0AAAAAACJ4TKEJ2B6CHSLMSJXSUWEUZLEKLKQ) + +## Create your index + +**1.** Click on `Import data`. + +![image](https://github.com/itzraiss/images/blob/main/Captura%20de%20tela%202023-11-26%20152107.png) + +**2.** Follow the Microsoft tutorial.[https://learn.microsoft.com/en-us/azure/search/search-get-started-portal](https://learn.microsoft.com/en-us/azure/search/search-get-started-portal), after finishing, save the name given to the index somewhere. + +**3.** Now you have your `AZURE_AI_SEARCH_INDEX_NAME`, copy and save it in a local safe place. + +## Get the Endpoint + +**1.** In the `Url:` you have your `AZURE_AI_SEARCH_SERVICE_ENDPOINT`, copy and save it in a local safe place. + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20152107.png?token=GHSAT0AAAAAACJ4TKEJIHDRS263BMLEAWQIZLEKSLQ) + +**2.** On the left panel, click on `keys`. + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20165630.png?token=GHSAT0AAAAAACJ4TKEII4DDP35JXEJVDK4QZLEKLOQ) + +**3.** Click on `Add` and insert a name for your key. + +**4.** Copy the key to get `AZURE_AI_SEARCH_API_KEY`. + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20152140.png?token=GHSAT0AAAAAACJ4TKEIIMEY6VXUAHHJMINKZLEKLQQ) + +# Configure in LibreChat: + +**1.** Access the Plugins and click to install Azure AI Search. + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20170057.png?token=GHSAT0AAAAAACJ4TKEJT2ZGJVG4KDBEPXT2ZLEKLMA) + +**2.** Fill in the Endpoint, Index Name, and API Key, and click on `Save`. + +# Conclusion + +![image](https://raw.githubusercontent.com/itzraiss/images/main/Captura%20de%20tela%202023-11-26%20150249.png?token=GHSAT0AAAAAACJ4TKEJBIPW4PXDAHMYG5HGZLEKTIQ) + +Now, you will be able to conduct searches using Azure AI Search. Congratulations! 🎉🎉 + +## Optional + +The following are configuration values that are not required but can be specified as parameters during a search. + +If there are concerns that the search result data may be too large and exceed the prompt size, consider reducing the size of the search result data by using AZURE_AI_SEARCH_SEARCH_OPTION_TOP and AZURE_AI_SEARCH_SEARCH_OPTION_SELECT. + +For details on each parameter, please refer to the following document: +https://learn.microsoft.com/en-us/rest/api/searchservice/search-documents + +```env +AZURE_AI_SEARCH_API_VERSION=2023-10-01-Preview +AZURE_AI_SEARCH_SEARCH_OPTION_QUERY_TYPE=simple +AZURE_AI_SEARCH_SEARCH_OPTION_TOP=3 +AZURE_AI_SEARCH_SEARCH_OPTION_SELECT=field1, field2, field3 +``` + +#### AZURE_AI_SEARCH_API_VERSION + +Specify the version of the search API. When using new features such as semantic search or vector search, you may need to specify the preview version. The default value is `2023-11-1`. + +#### AZURE_AI_SEARCH_SEARCH_OPTION_QUERY_TYPE + +Specify `simple` or `full`. The default value is `simple`. + +#### AZURE_AI_SEARCH_SEARCH_OPTION_TOP + +Specify the number of items to search for. The default value is 5. + +#### AZURE_AI_SEARCH_SEARCH_OPTION_SELECT + +Specify the fields of the index to be retrieved, separated by commas. Please note that these are not the fields to be searched. diff --git a/docs/features/plugins/azure_cognitive_search.md b/docs/features/plugins/azure_cognitive_search.md deleted file mode 100644 index 9954968df..000000000 --- a/docs/features/plugins/azure_cognitive_search.md +++ /dev/null @@ -1,57 +0,0 @@ -# Azure Cognitive Search Plugin -Through the plugins endpoint, you can use Azure Cognitive Search for answers to your questions with assistance from GPT. - -## Configurations - -### Required - -To get started, you need to get a Azure Cognitive Search endpoint URL, index name, and a API Key. You can then define these as follows in your `.env` file: -```env -AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT="..." -AZURE_COGNITIVE_SEARCH_INDEX_NAME="..." -AZURE_COGNITIVE_SEARCH_API_KEY="..." -``` - -### AZURE_COGNITIVE_SEARCH_SERVICE_ENDPOINT - -This is the URL of the search endpoint. It can be obtained from the top page of the search service in the Cognitive Search management console (e.g., 'https://example.search.windows.net'). - -### AZURE_COGNITIVE_SEARCH_INDEX_NAME - -This is the name of the index to be searched (e.g., 'hotels-sample-index'). - -### AZURE_COGNITIVE_SEARCH_API_KEY - -This is the authentication key to use when utilizing the search endpoint. Please issue it from the management console. Use the Value, not the name of the authentication key. - -### Optional - -The following are configuration values that are not required but can be specified as parameters during a search. - -If there are concerns that the search result data may be too large and exceed the prompt size, consider reducing the size of the search result data by using AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP and AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_SELECT. - -For details on each parameter, please refer to the following document: -https://learn.microsoft.com/en-us/rest/api/searchservice/search-documents - -```env -AZURE_COGNITIVE_SEARCH_API_VERSION=2023-07-01-Preview -AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_QUERY_TYPE=simple -AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP=3 -AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_SELECT=field1,field2,field3 -``` - -#### AZURE_COGNITIVE_SEARCH_API_VERSION - -Specify the version of the search API. When using new features such as semantic search, you may need to specify the preview version. The default value is '2020-06-30'. - -#### AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_QUERY_TYPE - -Specify 'simple' or 'full'. The default value is 'simple'. - -#### AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_TOP - -Specify the number of items to search for. The default value is 5. - -#### AZURE_COGNITIVE_SEARCH_SEARCH_OPTION_SELECT - -Specify the fields of the index to be retrieved, separated by commas. Please note that these are not the fields to be searched. \ No newline at end of file diff --git a/docs/install/free_ai_apis.md b/docs/install/free_ai_apis.md index e894f0b6f..25e26fdf1 100644 --- a/docs/install/free_ai_apis.md +++ b/docs/install/free_ai_apis.md @@ -2,7 +2,7 @@ There are APIs offering free/free-trial access to AI APIs via reverse proxy. -Here is a well-maintained public list of [Free AI APIs](https://github.com/NovaOSS/free-ai-apis) that may or may not be compatible with LibreChat +Here is a well-maintained public list of [Free AI APIs](https://github.com/zukixa/cool-ai-stuff) that may or may not be compatible with LibreChat ### [OpenRouter](https://openrouter.ai/) ⇆ (preferred) diff --git a/mkdocs.yml b/mkdocs.yml index 7bac2b8e1..211d520e6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -100,7 +100,7 @@ nav: - Google: 'features/plugins/google_search.md' - Stable Diffusion: 'features/plugins/stable_diffusion.md' - Wolfram: 'features/plugins/wolfram.md' - - Azure Cognitive Search: 'features/plugins/azure_cognitive_search.md' + - Azure AI Search: 'features/plugins/azure_ai_search.md' - Make Your Own Plugin: 'features/plugins/make_your_own.md' - Using official ChatGPT Plugins: 'features/plugins/chatgpt_plugins_openapi.md' - Automated Moderation: 'features/mod_system.md' diff --git a/package-lock.json b/package-lock.json index c8e72a812..a4dc94bf6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "license": "ISC", "dependencies": { "@anthropic-ai/sdk": "^0.5.4", - "@azure/search-documents": "^11.3.2", + "@azure/search-documents": "^12.0.0", "@keyv/mongo": "^2.1.8", "@keyv/redis": "^2.8.0", "axios": "^1.3.4", @@ -1451,16 +1451,16 @@ } }, "node_modules/@azure/core-http-compat": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@azure/core-http-compat/-/core-http-compat-1.3.0.tgz", - "integrity": "sha512-ZN9avruqbQ5TxopzG3ih3KRy52n8OAbitX3fnZT5go4hzu0J+KVPSzkL+Wt3hpJpdG8WIfg1sBD1tWkgUdEpBA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@azure/core-http-compat/-/core-http-compat-2.0.1.tgz", + "integrity": "sha512-xpQZz/q7E0jSW4rckrTo2mDFDQgo6I69hBU4voMQi7REi6JRW5a+KfVkbJCFCWnkFmP6cAJ0IbuudTdf/MEBOQ==", "dependencies": { "@azure/abort-controller": "^1.0.4", "@azure/core-client": "^1.3.0", "@azure/core-rest-pipeline": "^1.3.0" }, "engines": { - "node": ">=12.0.0" + "node": ">=14.0.0" } }, "node_modules/@azure/core-paging": { @@ -1475,9 +1475,9 @@ } }, "node_modules/@azure/core-rest-pipeline": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.12.1.tgz", - "integrity": "sha512-SsyWQ+T5MFQRX+M8H/66AlaI6HyCbQStGfFngx2fuiW+vKI2DkhtOvbYodPyf9fOe/ARLWWc3ohX54lQ5Kmaog==", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.12.2.tgz", + "integrity": "sha512-wLLJQdL4v1yoqYtEtjKNjf8pJ/G/BqVomAWxcKOR1KbZJyCEnCv04yks7Y1NhJ3JzxbDs307W67uX0JzklFdCg==", "dependencies": { "@azure/abort-controller": "^1.0.0", "@azure/core-auth": "^1.4.0", @@ -1490,7 +1490,7 @@ "tslib": "^2.2.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=16.0.0" } }, "node_modules/@azure/core-tracing": { @@ -1505,15 +1505,15 @@ } }, "node_modules/@azure/core-util": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.4.0.tgz", - "integrity": "sha512-eGAyJpm3skVQoLiRqm/xPa+SXi/NPDdSHMxbRAz2lSprd+Zs+qrpQGQQ2VQ3Nttu+nSZR4XoYQC71LbEI7jsig==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.6.1.tgz", + "integrity": "sha512-h5taHeySlsV9qxuK64KZxy4iln1BtMYlNt5jbuEFN3UFSAd1EwKg/Gjl5a6tZ/W8t6li3xPnutOx7zbDyXnPmQ==", "dependencies": { "@azure/abort-controller": "^1.0.0", "tslib": "^2.2.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=16.0.0" } }, "node_modules/@azure/logger": { @@ -1528,13 +1528,13 @@ } }, "node_modules/@azure/search-documents": { - "version": "11.3.2", - "resolved": "https://registry.npmjs.org/@azure/search-documents/-/search-documents-11.3.2.tgz", - "integrity": "sha512-pJBY/DF+G2PJzUFGu+MvBcHWgXMg4QceoTSoMvelPi/g9ynVxjjHYUdlP2aei8/L7nOpFnbTmC5iKNIRCNbnGw==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@azure/search-documents/-/search-documents-12.0.0.tgz", + "integrity": "sha512-d9d53f2WWBpLHifk+LVn+AG52zuXvjgxJAdaH6kuT2qwrO1natcigtTgBM8qrI3iDYaDXsQhJSIMEgg9WKSoWA==", "dependencies": { "@azure/core-auth": "^1.3.0", "@azure/core-client": "^1.3.0", - "@azure/core-http-compat": "^1.2.0", + "@azure/core-http-compat": "^2.0.1", "@azure/core-paging": "^1.1.1", "@azure/core-rest-pipeline": "^1.3.0", "@azure/core-tracing": "^1.0.0", @@ -1543,7 +1543,7 @@ "tslib": "^2.2.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=18.0.0" } }, "node_modules/@babel/code-frame": {