From 6a15e58a6c56901383d75c5072edc9275faecb07 Mon Sep 17 00:00:00 2001 From: Karen Shaw Date: Wed, 14 Aug 2024 16:38:07 +0000 Subject: [PATCH] Truncate embedding text --- app/lib/meadow/indexing/v2/work.ex | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/lib/meadow/indexing/v2/work.ex b/app/lib/meadow/indexing/v2/work.ex index 5192b87cd..eacfc78c2 100644 --- a/app/lib/meadow/indexing/v2/work.ex +++ b/app/lib/meadow/indexing/v2/work.ex @@ -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 @@ -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: []