UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

753 lines 31.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GPT_PROMPT = void 0; /* Custom modules */ const createNodeDescriptor_1 = require("../../createNodeDescriptor"); const logic_1 = require("../logic"); const crypto_1 = require("crypto"); const prompt_1 = require("../nlu/generativeSlotFiller/prompt"); const errors_1 = require("../../../errors"); const transcripts_1 = require("../../../interfaces/transcripts/transcripts"); exports.GPT_PROMPT = (0, createNodeDescriptor_1.createNodeDescriptor)({ type: "completeText", defaultLabel: "LLM Prompt (legacy)", summary: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__DESCRIPTION", fields: [ { key: "llmProviderReferenceId", type: "llmSelect", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__LLM_SELECT__LABEL", defaultValue: "default", params: { required: true } }, { key: "prompt", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__PROMPT_SYSTEM__LABEL", type: "cognigyLLMText", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__PROMPT_SYSTEM__DESCRIPTION", params: { multiline: true, rows: 5, required: false }, defaultValue: undefined }, { key: "chatTranscriptSteps", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TRANSCRIPT_STEPS__LABEL", type: "slider", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TRANSCRIPT_STEPS__DESCRIPTION", defaultValue: 3, params: { min: 0, max: 10, step: 1 }, condition: { key: "useChatMode", value: true, } }, { key: "useChatMode", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__USE_CHAT__LABEL", type: "toggle", params: { required: true }, defaultValue: true }, { key: "samplingMethod", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__SAMPLING_METHOD__LABEL", type: "select", defaultValue: "temperature", params: { options: [ { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__SAMPLING_METHOD__OPTIONS__TEMPERATURE__LABEL", value: "temperature" }, { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__SAMPLING_METHOD__OPTIONS__TOP_PERCENTATGE__LABEL", value: "topP" } ] } }, { key: "temperature", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TEMPERATURE__LABEL", type: "slider", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TEMPERATURE__DESCRIPTION", defaultValue: 0.7, params: { min: 0, max: 1, step: 0.1 }, condition: { key: "samplingMethod", value: "temperature", } }, { key: "topP", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TOP_P__LABEL", type: "slider", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TOP_P__DESCRIPTION", defaultValue: 1, params: { min: 0, max: 1, step: 0.1 }, condition: { key: "samplingMethod", value: "topP", } }, { key: "maxTokens", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__MAX_TOKENS__LABEL", type: "slider", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__MAX_TOKENS__DESCRIPTION", defaultValue: 1000, params: { min: 1, max: 4000, step: 1 } }, { key: "frequencyPenalty", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__FREQUENCY_PENALTY__LABEL", type: "slider", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__FREQUENCY_PENALTY__DESCRIPTION", defaultValue: 0, params: { min: -2, max: 2, step: 0.1 } }, { key: "presencePenalty", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__PRESENCE_PENALTY__LABEL", type: "slider", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__PRESENCE_PENALTY__DESCRIPTION", defaultValue: 0, params: { min: -2, max: 2, step: 0.1 } }, { key: "useStop", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__USE_STOP__LABEL", type: "toggle", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__USE_STOP__DESCRIPTION", defaultValue: false }, { key: "stop", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STOP__LABEL", type: "textArray", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STOP__DESCRIPTION", condition: { key: "useStop", value: true } }, { key: "timeout", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TIMEOUT__LABEL", defaultValue: 5000, type: "number", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__TIMEOUT__DESCRIPTION", }, { key: "storeLocation", type: "select", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STORE_LOCATION__LABEL", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STORE_LOCATION__DESCRIPTION", defaultValue: "input", params: { options: [ { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STORE_LOCATION__OPTIONS__INPUT__LABEL", value: "input" }, { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STORE_LOCATION__OPTIONS__CONTEXT__LABEL", value: "context" }, { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STORE_LOCATION__OPTIONS__STREAM__LABEL", value: "stream" } ], required: true }, }, { key: "immediateOutput", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__IMMEDIATEOUTPUT__LABEL", type: "toggle", defaultValue: true, condition: { or: [ { key: "storeLocation", value: "input", }, { key: "storeLocation", value: "context", } ] } }, { key: "inputKey", type: "cognigyText", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__INPUT_KEY__LABEL", defaultValue: "promptResult", condition: { or: [ { key: "storeLocation", value: "input", }, { and: [ { key: "storeLocation", value: "stream", }, { key: "streamStoreCopyInInput", value: true, } ] } ] } }, { key: "contextKey", type: "cognigyText", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__CONTEXT_KEY__LABEL", defaultValue: "promptResult", condition: { key: "storeLocation", value: "context", } }, { key: "streamStopTokens", type: "textArray", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STREAM_STOP_TOKENS__LABEL", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STREAM_STOP_TOKENS__DESCRIPTION", defaultValue: [".", "!", "?", "\\n"], condition: { key: "storeLocation", value: "stream", } }, { key: "streamStopTokenOverrides", type: "textArray", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STREAM_STOP_TOKEN_OVERRIDES__LABEL", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STREAM_STOP_TOKEN_OVERRIDES__DESCRIPTION", defaultValue: ["\d+\."], condition: { key: "storeLocation", value: "stream", } }, { key: "streamDescription", type: "description", label: " ", params: { text: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STREAM_DESCRIPTION__TEXT" }, condition: { key: "storeLocation", value: "stream", } }, { key: "streamStoreCopyInInput", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STREAM_STORE_COPY__LABEL", type: "toggle", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__STREAM_STORE_COPY__DESCRIPTION", defaultValue: false, condition: { key: "storeLocation", value: "stream", } }, { key: "debugLogTokenCount", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__DEBUGLOGTOKENCOUNT__LABEL", type: "toggle", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__DEBUGLOGTOKENCOUNT__DESCRIPTION", defaultValue: false }, { key: "debugLogRequestAndCompletion", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__DEBUGLOGREQUESTANDCOMPLETION__LABEL", type: "toggle", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__DEBUGLOGREQUESTANDCOMPLETION__DESCRIPTION", defaultValue: false }, { key: "debugDescription", type: "description", label: " ", params: { text: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__DEBUG_DESCRIPTION__TEXT" } }, { key: "responseFormat", type: "select", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__RESPONSE_FORMAT__LABEL", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__RESPONSE_FORMAT__DESCRIPTION", defaultValue: "default", params: { options: [ { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__RESPONSE_FORMAT__OPTIONS__DEFAULT__LABEL", value: "default" }, { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__RESPONSE_FORMAT__OPTIONS__TEXT__LABEL", value: "text" }, { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__RESPONSE_FORMAT__OPTIONS__JSON__LABEL", value: "json_object" } ] }, }, { key: "detailedResults", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__DETAILED_RESULTS__LABEL", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__DETAILED_RESULTS__DESCRIPTION", type: "toggle", defaultValue: false, condition: { or: [ { key: "storeLocation", value: "input", }, { key: "storeLocation", value: "context", }, { and: [ { key: "storeLocation", value: "stream", }, { key: "streamStoreCopyInInput", value: true, } ] } ] } }, { key: "seed", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__SEED__LABEL", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__SEED__DESCRIPTION", type: "cognigyText", defaultValue: "" }, { key: "jsonStreamWarning", type: "description", label: " ", params: { text: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__JSONSTREAMWARNING__PARAM" }, condition: { and: [ { key: "responseFormat", value: "json_object" }, { key: "storeLocation", value: "stream", } ] } }, { key: "customModelOptions", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__CUSTOM_MODEL_OPTIONS__LABEL", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__CUSTOM_MODEL_OPTIONS__DESCRIPTION", type: "json", defaultValue: {} }, { key: "customRequestOptions", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__CUSTOM_REQUEST_OPTIONS__LABEL", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__CUSTOM_REQUEST_OPTIONS__DESCRIPTION", type: "json", defaultValue: {} }, { key: "logErrorToSystem", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__LOG_ERROR_TO_SYSTEM__LABEL", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__LOG_ERROR_TO_SYSTEM__DESCRIPTION", type: "toggle", defaultValue: false, }, { key: "errorHandling", type: "select", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__HANDLE_SERVICE_ERROR__LABEL", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__HANDLE_SERVICE_ERROR__DESCRIPTION", defaultValue: "continue", params: { options: [ { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__HANDLE_SERVICE_ERROR__OPTIONS__STOP__LABEL", value: "stop" }, { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__HANDLE_SERVICE_ERROR__OPTIONS__CONTINUE__LABEL", value: "continue" }, { label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__HANDLE_SERVICE_ERROR__OPTIONS__GOTO__LABEL", value: "goto" }, ] } }, { key: "errorMessage", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__ERROR_MESSAGE__LABEL", type: "cognigyText", description: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__ERROR_MESSAGE__DESCRIPTION", defaultValue: "", condition: { key: "errorHandling", value: "continue" } }, { key: "errorHandlingGotoTarget", type: "flowNode", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__FIELDS__ERROR__GOTO_NODE__LABEL", condition: { key: "errorHandling", value: "goto" } }, ], sections: [ { key: "advanced", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__SECTIONS__ADVANCED__LABEL", defaultCollapsed: true, fields: [ "model", "samplingMethod", "temperature", "topP", "maxTokens", "presencePenalty", "frequencyPenalty", "useStop", "stop", "timeout", "responseFormat", "jsonStreamWarning", "seed" ] }, { key: "storage", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__SECTIONS__STORAGE__LABEL", defaultCollapsed: true, fields: [ "storeLocation", "jsonStreamWarning", "streamDescription", "inputKey", "contextKey", "immediateOutput", "streamStopTokens", "streamStopTokenOverrides", "streamStoreCopyInInput", "detailedResults" ] }, { key: "errorHandling", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__SECTIONS__ERROR_HANDLING__LABEL", defaultCollapsed: true, fields: [ "logErrorToSystem", "errorHandling", "errorMessage", "errorHandlingGotoTarget", ] }, { key: "customOptions", label: "UI__NODE_EDITOR__SERVICE__GPT_PROMPT__SECTIONS__CUSTOM_OPTIONS__LABEL", defaultCollapsed: true, fields: [ "customModelOptions", "customRequestOptions" ] }, { key: "debugging", label: "UI__NODE_EDITOR__SECTIONS__DEBUG_SETTINGS__LABEL", defaultCollapsed: true, fields: [ "debugDescription", "debugLogTokenCount", "debugLogRequestAndCompletion" ] } ], form: [ { type: "field", key: "llmProviderReferenceId" }, { type: "field", key: "prompt" }, { type: "field", key: "useChatMode" }, { type: "field", key: "chatTranscriptSteps" }, { type: "section", key: "advanced" }, { type: "section", key: "storage" }, { type: "section", key: "errorHandling" }, { type: "section", key: "customOptions" }, { type: "section", key: "debugging" }, ], appearance: {}, tags: ["ai", "llm", "gpt", "generative ai", "openai", "azure", "prompt"], function: async ({ cognigy, config, nodeId }) => { var _a, _b, _c, _d; const { api, input } = cognigy; const { temperature, maxTokens, topP, presencePenalty, frequencyPenalty, useStop, stop, storeLocation, contextKey, inputKey, timeout, streamStopTokens, streamStopTokenOverrides, debugLogTokenCount, debugLogRequestAndCompletion, llmProviderReferenceId, useChatMode, chatTranscriptSteps, responseFormat, streamStoreCopyInInput, detailedResults, seed, immediateOutput, customModelOptions, customRequestOptions, errorHandling = "continue", // default behavior for LLM Prompt node was, continue its execution even though an error occurred (deviating it from the SEO node) & do not output an error message on UI explicitly. However, error is always stored in the input or context object. We can use an extra "say" node to output it. errorHandlingGotoTarget, errorMessage, logErrorToSystem, } = config; let prompt = config.prompt; const { traceId } = input; // check if custom variables are used and if they have a length modifier // works only for a single variable per prompt if (prompt.includes("@cognigyRecentConversation")) { let turnLimit; if (prompt.match(/@cognigyRecentConversation:(\d+)/)) { // @cognigyRecentConversation has a length modifier (e.g. @cognigyRecentConversation:5), so we just want to return the top 5 turns turnLimit = Number(prompt.match(/@cognigyRecentConversation:(\d+)/)[1]); } const recentConversation = (0, prompt_1.createLastConverationString)(cognigy.lastConversationEntries, turnLimit) + "\n"; prompt = prompt.replace(/@cognigyRecentConversation(:\d+)?/, recentConversation); } if (prompt.includes("@cognigyRecentUserInputs")) { let turnLimit; if (prompt.match(/@cognigyRecentUserInputs:(\d+)/)) { // @cognigyRecentUserInputs has a length modifier (e.g. @cognigyRecentUserInputs:5), so we just want to return the top 5 entries turnLimit = Number(prompt.match(/@cognigyRecentUserInputs:(\d+)/)[1]); } const recentUserInputs = (0, prompt_1.createLastUserInputString)(cognigy.lastConversationEntries, turnLimit) + "\n"; prompt = prompt.replace(/@cognigyRecentUserInputs(:\d+)?/, recentUserInputs); } // handle errors from external services, depending on the settings const handleServiceError = async (error) => { var _a, _b, _c; const compactError = { name: error === null || error === void 0 ? void 0 : error.name, code: error === null || error === void 0 ? void 0 : error.code, message: (error === null || error === void 0 ? void 0 : error.message) || error }; // return the requestId if it exist in the error obj. if ((_a = error === null || error === void 0 ? void 0 : error.meta) === null || _a === void 0 ? void 0 : _a.requestId) { compactError["requestId"] = (_b = error === null || error === void 0 ? void 0 : error.meta) === null || _b === void 0 ? void 0 : _b.requestId; } if ((_c = error === null || error === void 0 ? void 0 : error.originalErrorDetails) === null || _c === void 0 ? void 0 : _c.code) { compactError.code = error.originalErrorDetails.code; } const errorResponse = { error: compactError, }; // add error to context or input switch (storeLocation) { case "context": // @ts-ignore api.addToContext(contextKey, errorResponse, "simple"); break; default: api.addToInput(inputKey, errorResponse); } if (errorHandling === "continue") { // output the timeout message if (errorMessage) { await api.output(errorMessage, null); } } else if (errorHandling === "goto") { if (!errorHandlingGotoTarget) { throw new Error("GoTo Target is required"); } const gotoParams = { cognigy, childConfigs: [], nodeId, config: { flowNode: { flow: errorHandlingGotoTarget.flow, node: errorHandlingGotoTarget.node, }, injectedText: undefined, injectedData: undefined, executionMode: "continue", absorbContext: false } }; await logic_1.GO_TO.function(gotoParams); } else { throw new errors_1.InternalServerError(error === null || error === void 0 ? void 0 : error.message, { traceId }); } }; try { const isStreamingChannel = input.channel === "webchat3" || input.channel === "adminconsole"; const _messageId = (0, crypto_1.randomUUID)(); const data = { prompt, temperature, maxTokens, topP, presencePenalty, frequencyPenalty, timeoutInMs: timeout, useCase: "promptNode", stream: storeLocation === "stream", streamOnDataHandler: (text) => { text = isStreamingChannel ? text : text.trim(); if (text) { api.output(text, { _cognigy: { _messageId, _preventTranscript: true } }); } }, streamStopTokens, streamStopTokenOverrides, preventNewLineRemoval: isStreamingChannel ? true : false, // set to true in order to get token usage detailedResults: true, seed: Number(seed) ? Number(seed) : undefined, customModelOptions, customRequestOptions }; if (useStop) { data["stop"] = stop; } // llmProviderReferenceId `default` value is not a responseFormat, rather it is LLM Model default selection. if (llmProviderReferenceId && llmProviderReferenceId !== "default") { data["llmProviderReferenceId"] = llmProviderReferenceId; } if (responseFormat && responseFormat !== "default") { data["responseFormat"] = responseFormat; } let debugPrompt = prompt; if (useChatMode && (prompt || chatTranscriptSteps)) { data["chat"] = (0, prompt_1.createLastConversationChatObject)(cognigy.lastConversationEntries, prompt, chatTranscriptSteps); data.prompt = ""; debugPrompt = JSON.stringify(data["chat"]); } const response = await api.runGenerativeAIPrompt(data, "gptPromptNode"); const isFollowSessionActive = api.getMetadata().isFollowSessionActive; // if we're in adminconsole or following a session, process debugging options (input.endpointType === "adminconsole" || isFollowSessionActive) && (0, prompt_1.writeLLMDebugLogs)("LLM Prompt", debugPrompt, response, debugLogTokenCount, debugLogRequestAndCompletion, cognigy); let responseToStore; if (detailedResults) { responseToStore = response; } else { responseToStore = response.result; } if (storeLocation === "context") { api.addToContext(contextKey, responseToStore, "simple"); // output result immediately if toggle is set if (immediateOutput) { const resultToOutput = typeof ((response === null || response === void 0 ? void 0 : response.result) || response) === "object" ? JSON.stringify((response === null || response === void 0 ? void 0 : response.result) || response, undefined, 2) : (response === null || response === void 0 ? void 0 : response.result) || response; await api.output(resultToOutput, null); } } else if (storeLocation === "input" || (storeLocation === "stream" && streamStoreCopyInInput)) { // @ts-ignore api.addToInput(inputKey, responseToStore); // output result immediately if toggle is set and we're storing into input // this means we don't output the result again if we streamed if (storeLocation === "input" && immediateOutput) { const resultToOutput = typeof ((response === null || response === void 0 ? void 0 : response.result) || response) === "object" ? JSON.stringify((response === null || response === void 0 ? void 0 : response.result) || response, undefined, 2) : (response === null || response === void 0 ? void 0 : response.result) || response; await api.output(resultToOutput, null); } else if (storeLocation === "stream") { const transcriptContent = { role: transcripts_1.TranscriptRole.ASSISTANT, type: transcripts_1.TranscriptEntryType.OUTPUT, source: "assistant", payload: { text: ((response === null || response === void 0 ? void 0 : response.result) || response), data: {}, } }; await api.addTranscriptStep(transcriptContent); } if (storeLocation === "stream" && responseToStore.finishReason) { // send the finishReason as last output for a stream (_a = api.output) === null || _a === void 0 ? void 0 : _a.call(api, "", { _cognigy: { _preventTranscript: true, _messageId, _finishReason: responseToStore.finishReason, } }); } } } catch (error) { const errorDetailsBase = { name: error === null || error === void 0 ? void 0 : error.name, code: (error === null || error === void 0 ? void 0 : error.code) || (error === null || error === void 0 ? void 0 : error.httpStatusCode), message: (error === null || error === void 0 ? void 0 : error.message) || ((_b = error.originalErrorDetails) === null || _b === void 0 ? void 0 : _b.message), }; const errorDetails = Object.assign(Object.assign({}, errorDetailsBase), { originalErrorDetails: error === null || error === void 0 ? void 0 : error.originalErrorDetails }); // return the requestId if it exist in the error obj. if ((_c = error.meta) === null || _c === void 0 ? void 0 : _c.requestId) { errorDetails["meta"] = { requestId: (_d = error.meta) === null || _d === void 0 ? void 0 : _d.requestId }; } if (logErrorToSystem) { api.log("error", JSON.stringify(errorDetailsBase)); } api.logDebugError(errorDetailsBase, "UI__DEBUG_MODE__LLM_PROMPT__ERROR"); await handleServiceError(errorDetails); return; } } }); //# sourceMappingURL=GPTPrompt.js.map