How to use child nodes from a LangChain Code Node?

Hello,

I am trying to use the LangChain code node to take a text as input, split it, and return the embeddings. I wanted to get use a document loader/text splitter node to have it be easily configurable, but I eventually gave up on it and hard coded the info since I couldn’t figure out how to use them from the code.

Now however I want to use the embeddings node. I have searched the docs and I can’t understand how to use the connected embeddings node. Even trying to output Object.jeys(the_node) ended up giving me no good answers as to a possible API the node exposed.

Given that I have chunks of text available, how embed them using the embeddings node? And possibly, as a step 2, how could I chunk it using a child textsplitter node as well or, better yet, use a child document loader node?

Information on your n8n setup

  • n8n version: 1.86.0
  • Database: PostgreSQL
  • n8n EXECUTIONS_PROCESS setting: Don’t know, probably the defaults
  • Running n8n via: Docker
  • Operating system: Linux probably

Found the issue! I simply forgot to resolve the promise.

const embedder = await this.getInputConnectionData("ai_embedding", 0);

After this, embedder works just as any Embedding LangChain object! Although it should be specified in the docs that this method returns a promise…

1 Like

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