Skip to content

Commit

Permalink
Merge pull request #4093 from nulib/5160-truncate
Browse files Browse the repository at this point in the history
Truncate embedding text
  • Loading branch information
kdid authored Aug 14, 2024
2 parents 5ab2c1c + 6a15e58 commit 8f3f145
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions app/lib/meadow/indexing/v2/work.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,26 @@ defmodule Meadow.Indexing.V2.Work do
end

@embedding_keys [
:abstract,
:title,
:description,
:collection,
:alternate_title,
:caption,
:collection,
:table_of_contents,
:abstract,
:contributor,
:creator,
:date_created,
:description,
:genre,
# :keywords,
:subject,
:style_period,
:language,
:location,
:physical_description_material,
:physical_description_size,
:publisher,
:scope_and_contents,
:source,
:subject,
:style_period,
:table_of_contents,
:title,
:technique
:technique,
:physical_description_material,
:physical_description_size,
]

defp prepare_embedding_field(map) do
Expand All @@ -115,10 +113,12 @@ defmodule Meadow.Indexing.V2.Work do
end)
|> Enum.join("\n")

Map.put(map, :embedding_text, value)
Map.put(map, :embedding_text_length, String.length(value))
|> Map.put(:embedding_text, String.slice(value, 0, 2048))
end

defp prepare_embedding_value(%{label: v}), do: prepare_embedding_value(v)
defp prepare_embedding_value(%{title: v}), do: prepare_embedding_value(v)

defp prepare_embedding_value([]), do: []

Expand Down

0 comments on commit 8f3f145

Please sign in to comment.