- 入门指南
- 主机管理
- 组织
- 租户和服务
- 身份验证和安全性
- 许可
- 帐户和角色
- 外部应用程序
- 在您的组织中进行测试
- Ai Trust Layer
- 通知
- 日志记录
- 故障排除
基于 Azure OpenAI 模板创建自定义 Integration Service 连接器,将部署在 Azure AI Foundry 中的 Mistrl 模型通过 AI Trust Layer 连接到 UiPath Agents。
本指南说明了如何通过 AI Trust Layer LLM 配置功能将 Microsoft Azure AI Foundry 中部署的 Mistral 模型连接到 UiPath 智能体。您可以基于 Azure OpenAI 模板创建一个自定义 Integration Service 连接器,并根据 Mistral 的 API 要求调整其请求挂钩。
先决条件
- 在集群中启用 BYO AI 网关。有关详细信息,请参阅配置 AI Trust Layer 。
- 在 Azure AI Foundry 中部署的 Mistral 模型(例如
mistral-small-2503) - 资源的 Azure AI Foundry 端点 URL
- Azure AI Foundry 资源的 API 密钥
- Automation Suite 中的组织管理员访问权限
- 访问 Integration Service 和连接器生成器
创建自定义连接器
- 导航到“管理员” > “AI Trust Layer” > “LLM 配置” ,然后选择“添加配置” 。
- 设置“租户” 、 “产品”和“功能”的值。
- 在“模型配置”下,在“LLM 名称”字段中输入自定义别名,并将“API 类型”设置为“OpenAI” 。
- 在“连接器”字段中,选择“创建自定义连接器” 。
- 选择“Azure OpenAI”模板,然后选择“创建连接器” 。系统将打开连接器生成器,其中已预先填充 Azure OpenAI 模板。
编辑连接器以实现 Mistral 兼容性
Azure AI Foundry 上的 Mistral 模型使用严格的架构验证,并且不接受 Azure OpenAI 模板默认发送的所有字段。在每个请求到达 Mistral 端点之前,连接器的preRequest挂钩必须解决这些差异。
| Azure OpenAI 模板发送 | Azure AI Foundry 上的 Mistral | 挂钩应用的分辨率 |
|---|---|---|
tool_choice: "required" 或对象形式 | "none"、 "auto"或"any" | 如果存在工具,则转换为"any" |
parallel_tool_calls 字段 | 不支持的字段 ( extra_forbidden ) | 已从请求正文中删除 |
max_completion_tokens | max_tokens | 字段已重命名 |
-
在连接器生成器中,打开“挂钩”部分,然后选择“preRequest”挂钩。
-
将整个挂钩主体替换为以下脚本:
// Normalize query params and payload for Mistral on Azure AI Foundry. // Removes unsupported fields and adapts tool semantics for Mistral's strict schema. const _reqPath = (typeof request_path !== 'undefined') ? request_path : ''; const _reqParams = (typeof request_parameters !== 'undefined') ? request_parameters : undefined; const _cfg = (typeof configuration !== 'undefined') ? configuration : undefined; if (['/query', '/v1/responses'].includes(_reqPath)) { return done(); } let apiVersion = (_cfg && _cfg['api-version']) ? _cfg['api-version'] : "2023-05-15"; if (_reqParams && _reqParams["api-version"]) { apiVersion = _reqParams["api-version"]; } if (['/listAllModels', '/auth_validation'].includes(_reqPath)) { apiVersion = (_cfg && _cfg['api-version']) ? _cfg['api-version'] : "2023-10-01-preview"; } // Resolve body across different runtime variable names let body = (typeof request_body !== 'undefined' && request_body) ? request_body : ((typeof request_vendor_body !== 'undefined' && request_vendor_body) ? request_vendor_body : ((typeof request !== 'undefined' && request && request.body) ? request.body : undefined)); if (body && typeof body === 'string') { try { body = JSON.parse(body); } catch (e) { /* leave as-is */ } } if (body && typeof body === 'object') { // Remove field rejected by Mistral's strict schema if (Object.prototype.hasOwnProperty.call(body, 'parallel_tool_calls')) { delete body.parallel_tool_calls; } // Normalize tool_choice: Mistral accepts only 'none', 'auto', or 'any' const _allowedToolChoice = new Set(['none', 'auto', 'any']); const _hasTools = Object.prototype.hasOwnProperty.call(body, 'tools') && Array.isArray(body.tools) && body.tools.length > 0; if (Object.prototype.hasOwnProperty.call(body, 'tool_choice')) { if (body.tool_choice === 'required') { body.tool_choice = 'any'; } else if (body.tool_choice && typeof body.tool_choice === 'object') { body.tool_choice = 'any'; } else if (typeof body.tool_choice === 'string' && !_allowedToolChoice.has(body.tool_choice)) { body.tool_choice = _hasTools ? 'any' : 'auto'; } } else if (_hasTools) { // Force tool usage: agent runtime expects tool calls when tools are configured body.tool_choice = 'any'; } // Rename max_completion_tokens to max_tokens if (Object.prototype.hasOwnProperty.call(body, 'max_completion_tokens')) { if (!Object.prototype.hasOwnProperty.call(body, 'max_tokens')) { body.max_tokens = body.max_completion_tokens; } delete body.max_completion_tokens; } } const out = { request_vendor_parameters: { "api-version": apiVersion } }; if (typeof request_body !== 'undefined') out.request_body = body; if (typeof request_vendor_body !== 'undefined') out.request_vendor_body = body; return done(out);// Normalize query params and payload for Mistral on Azure AI Foundry. // Removes unsupported fields and adapts tool semantics for Mistral's strict schema. const _reqPath = (typeof request_path !== 'undefined') ? request_path : ''; const _reqParams = (typeof request_parameters !== 'undefined') ? request_parameters : undefined; const _cfg = (typeof configuration !== 'undefined') ? configuration : undefined; if (['/query', '/v1/responses'].includes(_reqPath)) { return done(); } let apiVersion = (_cfg && _cfg['api-version']) ? _cfg['api-version'] : "2023-05-15"; if (_reqParams && _reqParams["api-version"]) { apiVersion = _reqParams["api-version"]; } if (['/listAllModels', '/auth_validation'].includes(_reqPath)) { apiVersion = (_cfg && _cfg['api-version']) ? _cfg['api-version'] : "2023-10-01-preview"; } // Resolve body across different runtime variable names let body = (typeof request_body !== 'undefined' && request_body) ? request_body : ((typeof request_vendor_body !== 'undefined' && request_vendor_body) ? request_vendor_body : ((typeof request !== 'undefined' && request && request.body) ? request.body : undefined)); if (body && typeof body === 'string') { try { body = JSON.parse(body); } catch (e) { /* leave as-is */ } } if (body && typeof body === 'object') { // Remove field rejected by Mistral's strict schema if (Object.prototype.hasOwnProperty.call(body, 'parallel_tool_calls')) { delete body.parallel_tool_calls; } // Normalize tool_choice: Mistral accepts only 'none', 'auto', or 'any' const _allowedToolChoice = new Set(['none', 'auto', 'any']); const _hasTools = Object.prototype.hasOwnProperty.call(body, 'tools') && Array.isArray(body.tools) && body.tools.length > 0; if (Object.prototype.hasOwnProperty.call(body, 'tool_choice')) { if (body.tool_choice === 'required') { body.tool_choice = 'any'; } else if (body.tool_choice && typeof body.tool_choice === 'object') { body.tool_choice = 'any'; } else if (typeof body.tool_choice === 'string' && !_allowedToolChoice.has(body.tool_choice)) { body.tool_choice = _hasTools ? 'any' : 'auto'; } } else if (_hasTools) { // Force tool usage: agent runtime expects tool calls when tools are configured body.tool_choice = 'any'; } // Rename max_completion_tokens to max_tokens if (Object.prototype.hasOwnProperty.call(body, 'max_completion_tokens')) { if (!Object.prototype.hasOwnProperty.call(body, 'max_tokens')) { body.max_tokens = body.max_completion_tokens; } delete body.max_completion_tokens; } } const out = { request_vendor_parameters: { "api-version": apiVersion } }; if (typeof request_body !== 'undefined') out.request_body = body; if (typeof request_vendor_body !== 'undefined') out.request_vendor_body = body; return done(out); -
在连接器设置中,将“基本 URL”设置为您的 Azure AI Foundry 端点:
https://{your-resource-name}.openai.azure.com/openai。 -
设置“身份验证类型”以匹配您的设置。本示例使用API 密钥(
customApiKey),但您可以使用任何受支持的身份验证类型,包括OAuth — 请相应地更新连接器设置。 -
选择“保存” ,然后发布连接器。
在 Integration Service 中创建连接
- 在 Integration Service 中,导航到“连接” ,然后选择“添加连接” 。
- 选择您发布的自定义连接器。
- 在“API 密钥”字段中,输入您的 Azure AI Foundry API 密钥。
- 在“Azure OpenAI 资源”字段中,输入您的资源名称,即端点 URL 的子域部分,不带
https://或.openai.azure.com。 - 选择“连接”以配置连接。
完成 LLM 配置
- 返回到“管理员” > “AI Trust Layer” > “LLM 配置” ,然后打开您启动的配置。
- 在“模型配置”下,将“连接器”设置为您已发布的连接器,将“连接” 设置为您创建的连接。
- 在“LLM 标识符”字段中,输入与 Azure AI Foundry 中显示的完全相同的部署名称。
备注:
LLM 标识符字段中的尾随空格会导致
DeploymentNotFound错误。保存前,请验证没有前导或尾随空格。 - 选择测试配置,以运行 AI Trust Layer 探测器。
- 如果探测器通过,请选择“保存” 。
结果
配置将保存,并且 Mistral 模型可用于您指定的产品和功能的 UiPath 智能体。调用通过 AI Trust Layer 路由,并显示在审核日志中的“来源:自定义连接”下。
如果您在创建自定义连接器时遇到问题,请联系 UiPath 支持团队获取帮助。