Issues with Embedding

Describe the problem/error/question

Extraction from Text File issues:
File Location is empty
File Created is correct
File Content is empty

As a result, when I ask the chatbot the answer to the question, it is unable to answer it because whereas the collection is created and their is metadata, there is no content embedded (which contains the answer to the question).

The issue seems to be with the node “Prepare Embedding Document”

When I look at the node the Javascript for File Contents {{ json.text }} is red (which I presume explains the content not being pushed to qdrant)

The javascript for File Location {{ [$json.directory, $json.fileName].join(‘/’) }} is green but it is not pushing the correct data to qdrant (it pushes “## file location\n/\n” (which as you can see is not correct).

Note I have edited the workflow to use my own local files, credentials and changed the extract from file type to be text instead of pdf.

What is the error message (if any)?

Trying to push data to qdrant after extracting from a text file is not working.

Please share your workflow

Share the output returned by the last node


[
{
"data": 
"This is a test document - the answer to the question is 5.\n"
}
]

Information on your n8n setup

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

I fixed the first issue of the file contents not being pushed - the javascript expression was not referencing the data object output form the previous node.

Now the content is being pushed to 'Prepare Embedding Document" node correctly and is making it into qdrant (and boy is that cool).

And I am guessing that the reason the file location is not being parsed is because it is also not using the correct expression (I see $json.directory in the variables node but there is no fileName variable set).

How do I set the $json.fileName variable?

Hi @ThatPrivacyGuy

I am not sure this is the correct answer to your question, but the file name is on the binary property, so you should be able to get the fileName with this
{{ $binary.data.fileName }}

Where can I find documentation about these objects and their properties please - I can’t seem to find it.

That didn’t work - now I get NULL for the file location in my points.

These are the expressions I am currently using in the node:

## file location
{{ [$json.directory, $binary.data.fileName].join('/') }}
## file created
{{ $now.toISO() }}
## file contents
{{ $json.data }}

The error in the node editor is ‘undefined’.

OK I have fixed this issue - I had to grab the file location and file name from a previous node as follows:

{{ $node["Read File"].json["directory"] }}/{{ $node["Read File"].json["fileName"] }}

1 Like

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