UiPath Documentation
test-cloud
latest
false
Guia do administrador do Test Cloud
Importante :
A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.

Guia de instruções: conexão do Mistral por meio da AI Trust Layer

Connect a Mistral model in Azure AI Foundry to UiPath Agents via AI Trust Layer using a custom Integration Service connector.

Observação:

This capability is currently generally available for enterprise customers upon request.

Este guia explica como conectar um modelo Mistral implantado no Microsoft Azure AI Foundry aos UiPath Agents por meio do recurso Configurações de LLM da AI Trust Layer. Você cria um conector personalizado do Integration Service baseado em um modelo do Azure OpenAI e adapta seu gancho de solicitação para os requisitos da API do Mistral.

Pré-requisitos

  • Custom connectors for AI Trust Layer enabled for your organization (currently available upon request for enterprise customers).
  • Um modelo Mistral implantado no Azure AI Foundry (por exemplo, mistral-small-2503)
  • O URL do endpoint do Azure AI Foundry para seu recurso
  • Uma chave de API para seu recurso Azure AI Foundry
  • Organization administrator access in Test Cloud
  • Acesso ao Integration Service e ao Connector Builder

Crie o conector personalizado

  1. Navegue até Admin > AI Trust Layer > configurações do LLM e selecione Adicionar configuração.
  2. Defina os valores de Tenant, Produto e Recurso .
  3. Em Configuração do modelo, insira um alias personalizado no campo Nome do LLM e defina o Tipo de API como OpenAI.
  4. No campo Conector , selecione Criar conector personalizado.
  5. Selecione o modelo Azure OpenAI e, em seguida, selecione Criar conector. O Connector Builder é aberto com o modelo Azure OpenAI pré-preenchido.

Edite o conector para compatibilidade com o Mistral

Os modelos Mistral no Azure AI Foundry usam uma validação de esquema rigorosa e não aceitam todos os campos que o modelo do Azure OpenAI envia por padrão. O gancho preRequest do conector deve resolver essas diferenças antes que cada solicitação atinja o ponto de extremidade do Mistral.

Envios de modelo do Azure OpenAIO Mistral no Azure AI Foundry esperaResolução aplicada pelo hook
tool_choice: "required" ou formulário de objeto"none", "auto", ou "any"Traduzido para "any" quando há ferramentas presentes
parallel_tool_calls CampoCampo não compatível (extra_forbidden)Removido do corpo da solicitação
max_completion_tokensmax_tokensO campo foi renomeado
  1. No Construtor de Conector, abra a seção Gatilhos e selecione o hook preRequest .

  2. Substitua todo o corpo do hook pelo seguinte script:

    // 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);
    
  3. Nas configurações do conector, defina o URL base como seu endpoint do Azure AI Foundry: https://{your-resource-name}.openai.azure.com/openai.

  4. Defina o Tipo de autenticação para corresponder à sua configuração. Este exemplo usa a chave de API (customApiKey), mas você pode usar qualquer tipo de autenticação compatível, incluindo OAuth — atualize devidamente as configurações do conector.

  5. Selecione Salvar.

Crie uma conexão no Integration Service

  1. No Integration Service, navegue até Conexões e selecione Adicionar conexão.
  2. Selecione o conector personalizado que você publicou.
  3. No campo chave de API , insira sua chave de API do Azure AI Foundry.
  4. No campo Recurso do Azure OpenAI , insira seu nome do recurso — a parte do subdomínio do URL do seu ponto de extremidade, sem https:// ou .openai.azure.com.
  5. Selecione Conectar para provisionar a conexão.

Conclua a configuração do LLM

  1. Retorne ao Administrador > AI Trust Layer > configurações do LLM e abra a configuração que você iniciou.
  2. Em Configuração do modelo, defina Conector como seu conector publicado e Conexão como a conexão que você criou.
  3. No campo Identificador do LLM, insira o nome da implantação exatamente como ele aparece no Azure AI Foundry.
    Observação:

    Espaços à direita no campo Identificador do LLM causam um erro DeploymentNotFound . Verifique se não há espaços à esquerda ou à direita antes de salvar.

  4. Selecione Configuração de teste para executar a investigação da AI Trust Layer.
  5. Se a investigação for bem-sucedida, selecione Salvar.

Resultado

A configuração é salva e o modelo Mistral está disponível para os Agentes da UiPath para o produto e a funcionalidade que você especificou. As chamadas são encaminhadas por meio da AI Trust Layer e aparecem no log de auditoria em Origem: conexão personalizada.

Observação:

Se você encontrar problemas ao criar um conector personalizado, entre em contato com o Suporte da UiPath para obter assistência.

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades