UNPKG

n8n-nodes-openai-analytics

Version:
44 lines 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createEmbeddings = void 0; async function createEmbeddings(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); // API 응답을 IDataObject로 변환 const jsonResponse = {}; Object.assign(jsonResponse, embeddingsResponse); return { json: jsonResponse, }; } exports.createEmbeddings = createEmbeddings; //# sourceMappingURL=createEmbeddings.js.map