"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildAssistantChatItem = buildAssistantChatItem; exports.buildChatInitItem = buildChatInitItem; exports.buildChatItem = buildChatItem; exports.buildConversation = buildConversation; exports.buildFunction = buildFunction; exports.buildFunctionChatItem = buildFunctionChatItem; exports.buildFunctionElasticsearch = void 0; exports.buildFunctionServiceSummary = buildFunctionServiceSummary; exports.buildSystemChatItem = buildSystemChatItem; exports.buildTimelineItems = buildTimelineItems; exports.buildUserChatItem = buildUserChatItem; var _lodash = require("lodash"); var _types = require("../../common/types"); var _get_assistant_setup_message = require("../service/get_assistant_setup_message"); /* * 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. */ function buildChatItem(params) { return (0, _lodash.merge)({ id: (0, _lodash.uniqueId)(), title: '', actions: { canCopy: true, canEdit: false, canGiveFeedback: false, canRegenerate: params.role === _types.MessageRole.Assistant }, display: { collapsed: false, hide: false }, currentUser: { username: 'elastic' }, loading: false }, params); } function buildSystemChatItem(params) { return buildChatItem({ role: _types.MessageRole.System, ...params }); } function buildChatInitItem() { return buildChatItem({ role: _types.MessageRole.User, title: 'started a conversation', actions: { canEdit: false, canCopy: true, canGiveFeedback: false, canRegenerate: false } }); } function buildUserChatItem(params) { return buildChatItem({ role: _types.MessageRole.User, content: "What's a function?", actions: { canCopy: true, canEdit: true, canGiveFeedback: false, canRegenerate: true }, ...params }); } function buildAssistantChatItem(params) { return buildChatItem({ role: _types.MessageRole.Assistant, content: `In computer programming and mathematics, a function is a fundamental concept that represents a relationship between input values and output values. It takes one or more input values (also known as arguments or parameters) and processes them to produce a result, which is the output of the function. The input values are passed to the function, and the function performs a specific set of operations or calculations on those inputs to produce the desired output. A function is often defined with a name, which serves as an identifier to call and use the function in the code. It can be thought of as a reusable block of code that can be executed whenever needed, and it helps in organizing code and making it more modular and maintainable.`, actions: { canCopy: true, canEdit: false, canRegenerate: true, canGiveFeedback: true }, ...params }); } function buildFunctionChatItem(params) { return buildChatItem({ role: _types.MessageRole.User, title: 'executed a function', function_call: { name: 'leftpad', arguments: '{ foo: "bar" }', trigger: _types.MessageRole.Assistant }, ...params }); } function buildTimelineItems() { return { items: [buildSystemChatItem(), buildUserChatItem(), buildAssistantChatItem()] }; } function buildConversation(params) { return { '@timestamp': '', user: { name: 'foo' }, conversation: { id: (0, _lodash.uniqueId)(), title: '', last_updated: '' }, messages: [(0, _get_assistant_setup_message.getAssistantSetupMessage)({ contexts: [] })], labels: {}, numeric_labels: {}, namespace: '', ...params }; } function buildFunction() { return { options: { name: 'elasticsearch', contexts: ['core'], description: 'Call Elasticsearch APIs on behalf of the user', descriptionForUser: 'Call Elasticsearch APIs on behalf of the user', parameters: { type: 'object', properties: { method: { type: 'string', description: 'The HTTP method of the Elasticsearch endpoint', enum: ['GET', 'PUT', 'POST', 'DELETE', 'PATCH'] }, path: { type: 'string', description: 'The path of the Elasticsearch endpoint, including query parameters' } }, required: ['method', 'path'] } }, respond: async (options, signal) => ({}) }; } const buildFunctionElasticsearch = buildFunction; exports.buildFunctionElasticsearch = buildFunctionElasticsearch; function buildFunctionServiceSummary() { return { options: { name: 'get_service_summary', contexts: ['core'], description: 'Gets a summary of a single service, including: the language, service version, deployments, infrastructure, alerting, etc. ', descriptionForUser: 'Get a summary for a single service.', parameters: { type: 'object' } }, respond: async (options, signal) => ({}) }; }