Skip to content

Commit

Permalink
Correct genai batchEncode example syntax (#1148)
Browse files Browse the repository at this point in the history
  • Loading branch information
JMHReif authored Jan 9, 2025
1 parent ddc8aa6 commit a36e269
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/ROOT/pages/genai-integrations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ WITH collect(m) AS moviesList // <1>
100 AS batchSize // <2>
UNWIND range(0, total, batchSize) AS batchStart // <3>
CALL (moviesList, batchStart, batchSize) { // <4>
WITH [movie IN moviesList[batchStart .. batchStart + batchSize] | movie.title || ': ' || movie.plot] AS resources // <5>
WITH [movie IN moviesList[batchStart .. batchStart + batchSize] | movie.title || ': ' || movie.plot] AS batch // <5>
CALL genai.vector.encodeBatch(batch, 'OpenAI', { token: $token }) YIELD index, vector
CALL db.create.setNodeVectorProperty(moviesList[batchStart + index], 'embedding', vector) // <6>
} IN TRANSACTIONS OF 1 ROW <7>
Expand All @@ -199,7 +199,7 @@ Too large a batch size may also exceed the provider's threshold.
<4> A xref:subqueries/subqueries-in-transactions.adoc[`CALL` subquery] executes a separate transaction for each batch.
Note that this `CALL` subquery uses a xref:subqueries/call-subquery.adoc#variable-scope-clause[variable scope clause] (introduced in Neo4j 5.23) to import variables.
If you are using an older version of Neo4j, use an xref:subqueries/call-subquery.adoc#importing-with[importing `WITH` clause] instead.
<5> `resources` is a list of strings, each being the concatenation of `title` and `plot` of one movie.
<5> `batch` is a list of strings, each being the concatenation of `title` and `plot` of one movie.
<6> The procedure sets `vector` as value for the property named `embedding` for the node at position `batchStart + index` in the `moviesList`.
<7> Set to `1` the amount of batches to be processed at once.
Expand Down

0 comments on commit a36e269

Please sign in to comment.