UNPKG

n8n-nodes-openai-analytics

Version:
41 lines 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createEmbedding = void 0; async function createEmbedding(context) { const { openai, functionThis, i } = context; const inputType = functionThis.getNodeParameter('inputType', i); let input = ''; if (inputType === 'singleText') { input = functionThis.getNodeParameter('text', i); } else if (inputType === 'multipleTexts') { input = functionThis.getNodeParameter('texts', i); } else if (inputType === 'jsonInput') { const jsonData = functionThis.getNodeParameter('jsonInput', i); input = JSON.parse(jsonData); } const options = functionThis.getNodeParameter('options', i); // 임베딩 생성을 위한 파라미터 구성 const embeddingParams = { model: functionThis.getNodeParameter('embeddingModel', i), input, }; // 추가 옵션 적용 if (options.dimensions && options.dimensions > 0) { embeddingParams.dimensions = options.dimensions; } if (options.encodingFormat) { embeddingParams.encoding_format = options.encodingFormat; } if (options.user) { embeddingParams.user = options.user; } // 임베딩 생성 const embeddingsResponse = await openai.embeddings.create(embeddingParams); return { json: { ...embeddingsResponse } }; } exports.createEmbedding = createEmbedding; //# sourceMappingURL=createEmbedding.js.map