"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GenAiStreamingResponseSchema = exports.GenAiStreamActionParamsSchema = exports.GenAiSecretsSchema = exports.GenAiRunActionResponseSchema = exports.GenAiRunActionParamsSchema = exports.GenAiDashboardActionResponseSchema = exports.GenAiDashboardActionParamsSchema = exports.GenAiConfigSchema = void 0; var _configSchema = require("@kbn/config-schema"); var _constants = require("./constants"); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ // Connector schema const GenAiConfigSchema = _configSchema.schema.oneOf([_configSchema.schema.object({ apiProvider: _configSchema.schema.oneOf([_configSchema.schema.literal(_constants.OpenAiProviderType.AzureAi)]), apiUrl: _configSchema.schema.string() }), _configSchema.schema.object({ apiProvider: _configSchema.schema.oneOf([_configSchema.schema.literal(_constants.OpenAiProviderType.OpenAi)]), apiUrl: _configSchema.schema.string(), defaultModel: _configSchema.schema.string({ defaultValue: _constants.DEFAULT_OPENAI_MODEL }) })]); exports.GenAiConfigSchema = GenAiConfigSchema; const GenAiSecretsSchema = _configSchema.schema.object({ apiKey: _configSchema.schema.string() }); // Run action schema exports.GenAiSecretsSchema = GenAiSecretsSchema; const GenAiRunActionParamsSchema = _configSchema.schema.object({ body: _configSchema.schema.string() }); // Execute action schema exports.GenAiRunActionParamsSchema = GenAiRunActionParamsSchema; const GenAiStreamActionParamsSchema = _configSchema.schema.object({ body: _configSchema.schema.string(), stream: _configSchema.schema.boolean({ defaultValue: false }) }); exports.GenAiStreamActionParamsSchema = GenAiStreamActionParamsSchema; const GenAiStreamingResponseSchema = _configSchema.schema.any(); exports.GenAiStreamingResponseSchema = GenAiStreamingResponseSchema; const GenAiRunActionResponseSchema = _configSchema.schema.object({ id: _configSchema.schema.maybe(_configSchema.schema.string()), object: _configSchema.schema.maybe(_configSchema.schema.string()), created: _configSchema.schema.maybe(_configSchema.schema.number()), model: _configSchema.schema.maybe(_configSchema.schema.string()), usage: _configSchema.schema.object({ prompt_tokens: _configSchema.schema.number(), completion_tokens: _configSchema.schema.number(), total_tokens: _configSchema.schema.number() }, { unknowns: 'ignore' }), choices: _configSchema.schema.arrayOf(_configSchema.schema.object({ message: _configSchema.schema.object({ role: _configSchema.schema.string(), content: _configSchema.schema.string() }, { unknowns: 'ignore' }), finish_reason: _configSchema.schema.maybe(_configSchema.schema.string()), index: _configSchema.schema.maybe(_configSchema.schema.number()) }, { unknowns: 'ignore' })) }, { unknowns: 'ignore' }); // Run action schema exports.GenAiRunActionResponseSchema = GenAiRunActionResponseSchema; const GenAiDashboardActionParamsSchema = _configSchema.schema.object({ dashboardId: _configSchema.schema.string() }); exports.GenAiDashboardActionParamsSchema = GenAiDashboardActionParamsSchema; const GenAiDashboardActionResponseSchema = _configSchema.schema.object({ available: _configSchema.schema.boolean() }); exports.GenAiDashboardActionResponseSchema = GenAiDashboardActionResponseSchema;