Connecting an OpenAI Embedding node to the Neo4JVectorStore inside a LangChain Code node fails with error

Describe the problem/error/question

I’m trying to interact with a Neo4JVectorStore via the respective langchain class inside a LangChain Code node. The Node has one input, for an embedding (Using the OpenAI Embedding node there)

The code is similar to that shown as example for interaction with a redis vector store in https://community.n8n.io/t/using-redis-vectorstore-search-in-n8n/49301 :

// Import required modules
const { Neo4jVectorStore } = require('@langchain/community/vectorstores/neo4j_vector');
const { OpenAIEmbeddings } = require('@langchain/openai');

// Configuration for Neo4j
const neo4jConfig = {
  url: "neo4j+s://XXXXXXXX.databases.neo4j.io", 
  username: "XXXXXX", 
  password: "XXXXXX",
  indexName: "movienames",
  nodeLabel: "Actor",
  textNodeProperties: ["name"],
  embeddingNodeProperty: "embedding",
  searchType: "hybrid"
};

const embedding = await this.getInputConnectionData('ai_embedding', 0);

// You should have a populated Neo4j database to use this method
const neo4jVectorIndex = await Neo4jVectorStore.fromExistingGraph(
  embedding,
  neo4jConfig
);

await neo4jVectorIndex.close();
// Run the function and return the result
return true;

The code is inserted as execute type code

What is the error message (if any)?

Upon execution (via the “play” button above the node) I get the error message

“Problem in node ‘Create Embedding‘
embeddings.embedQuery is not a function null”

(“Create Embedding” is the name of the node the code lives in)

Share your workflow

##Instance info

  • n8n version: 1.67.1
  • Database (default: SQLite): sqlite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): executionMode: regular
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: TBD

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Done (as much as I could determine)

Hey @Markus_Walther

You need to set your input to max connections to 1 otherwise this.getInputConnectionData('ai_embedding', 0) returns an array.

image

Alternatively, if you need to use more than 1 embedding model

const [
  embeddingModel1,
  embeddingModel2
] = await this.getInputConnectionData('ai_embedding', 0)
2 Likes

Hey @Jim_Le ,

that was it. That fixed the problem.

Thank you very much!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.