@n8n/n8n-nodes-langchain
Version:
113 lines • 5.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmbeddingsGoogleVertex = void 0;
const google_vertexai_1 = require("@langchain/google-vertexai");
const ai_utilities_1 = require("@n8n/ai-utilities");
const n8n_workflow_1 = require("n8n-workflow");
const vertex_location_1 = require("../../llms/gemini-common/vertex-location");
const google_vertex_1 = require("../../../utils/google-vertex");
class EmbeddingsGoogleVertex {
constructor() {
this.methods = {
credentialTest: { googleVertexAiCredentialTest: google_vertex_1.googleVertexAiCredentialTest },
listSearch: {
async gcpProjectsList(filter, paginationToken) {
return await (0, google_vertex_1.searchGoogleProjects)(await this.getCredentials('googleApi'), filter, paginationToken);
},
},
};
this.description = {
displayName: 'Embeddings Google Vertex',
name: 'embeddingsGoogleVertex',
icon: 'file:google.svg',
group: ['transform'],
version: 1,
description: 'Use Google Vertex Embeddings',
defaults: {
name: 'Embeddings Google Vertex',
},
requestDefaults: {
ignoreHttpStatusErrors: true,
baseURL: '={{ $credentials.host }}',
},
credentials: google_vertex_1.googleVertexCredentials,
codex: {
categories: ['AI'],
subcategories: {
AI: ['Embeddings'],
},
resources: {
primaryDocumentation: [
{
url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsgooglevertex/',
},
],
},
},
inputs: [],
outputs: [n8n_workflow_1.NodeConnectionTypes.AiEmbedding],
outputNames: ['Embeddings'],
properties: [
google_vertex_1.googleVertexAuthentication,
(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. You can find available models <a href="https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/text-embeddings-api">here</a>.',
name: 'notice',
type: 'notice',
default: '',
},
{
displayName: 'Project ID',
name: 'projectId',
displayOptions: { show: { authentication: ['googleApi'] } },
type: 'resourceLocator',
default: { mode: 'list', value: '' },
required: true,
description: 'Select or enter your Google Cloud project ID',
modes: [
{
displayName: 'From List',
name: 'list',
type: 'list',
typeOptions: {
searchListMethod: 'gcpProjectsList',
},
},
{
displayName: 'ID',
name: 'id',
type: 'string',
},
],
},
{
displayName: 'Model Name',
name: 'modelName',
type: 'string',
description: 'The model which will generate the embeddings. <a href="https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/text-embeddings-api">Learn more</a>.',
default: 'text-embedding-005',
},
vertex_location_1.vertexLocationField,
],
};
}
async supplyData(itemIndex) {
const { projectId, credentials, location } = await (0, google_vertex_1.resolveGoogleVertexCredentials)(this, itemIndex);
const endpoint = (0, vertex_location_1.getVertexEndpoint)(location);
const modelName = this.getNodeParameter('modelName', itemIndex);
const embeddings = new google_vertexai_1.VertexAIEmbeddings({
authOptions: {
projectId,
credentials,
},
location,
...(endpoint ? { endpoint } : {}),
model: modelName,
});
return {
response: (0, ai_utilities_1.logWrapper)(embeddings, this),
};
}
}
exports.EmbeddingsGoogleVertex = EmbeddingsGoogleVertex;
//# sourceMappingURL=EmbeddingsGoogleVertex.node.js.map