UNPKG

@n8n/n8n-nodes-langchain

Version:

![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)

124 lines 5.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EmbeddingsGoogleGemini = void 0; const google_genai_1 = require("@langchain/google-genai"); const n8n_workflow_1 = require("n8n-workflow"); const ai_utilities_1 = require("@n8n/ai-utilities"); class EmbeddingsGoogleGemini { constructor() { this.description = { displayName: 'Embeddings Google Gemini', name: 'embeddingsGoogleGemini', icon: 'file:google.svg', group: ['transform'], version: 1, description: 'Use Google Gemini Embeddings', defaults: { name: 'Embeddings Google Gemini', }, requestDefaults: { ignoreHttpStatusErrors: true, baseURL: '={{ $credentials.host }}', }, credentials: [ { name: 'googlePalmApi', required: true, }, ], codex: { categories: ['AI'], subcategories: { AI: ['Embeddings'], }, resources: { primaryDocumentation: [ { url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsgooglegemini/', }, ], }, }, inputs: [], outputs: [n8n_workflow_1.NodeConnectionTypes.AiEmbedding], outputNames: ['Embeddings'], properties: [ (0, ai_utilities_1.getConnectionHintNoticeField)([n8n_workflow_1.NodeConnectionTypes.AiVectorStore]), { displayName: 'Each model is using different dimensional density for embeddings. Please make sure to use the same dimensionality for your vector store. The default model is using 768-dimensional embeddings.', name: 'notice', type: 'notice', default: '', }, { displayName: 'Model', name: 'modelName', type: 'options', description: 'The model which will generate the embeddings. <a href="https://developers.generativeai.google/api/rest/generativelanguage/models/list">Learn more</a>.', typeOptions: { loadOptions: { routing: { request: { method: 'GET', url: '/v1beta/models', }, output: { postReceive: [ { type: 'rootProperty', properties: { property: 'models', }, }, { type: 'filter', properties: { pass: "={{ $responseItem.name.includes('embedding') }}", }, }, { type: 'setKeyValue', properties: { name: '={{$responseItem.name}}', value: '={{$responseItem.name}}', description: '={{$responseItem.description}}', }, }, { type: 'sort', properties: { key: 'name', }, }, ], }, }, }, }, routing: { send: { type: 'body', property: 'model', }, }, default: 'models/gemini-embedding-001', }, ], }; } async supplyData(itemIndex) { this.logger.debug('Supply data for embeddings Google Gemini'); const modelName = this.getNodeParameter('modelName', itemIndex, 'models/gemini-embedding-001'); const credentials = await this.getCredentials('googlePalmApi'); const embeddings = new google_genai_1.GoogleGenerativeAIEmbeddings({ apiKey: credentials.apiKey, baseUrl: credentials.host, model: modelName, }); return { response: (0, ai_utilities_1.logWrapper)(embeddings, this), }; } } exports.EmbeddingsGoogleGemini = EmbeddingsGoogleGemini; //# sourceMappingURL=EmbeddingsGoogleGemini.node.js.map