From 232833ec02ae608909c17e5d50bc5263192dcc0e Mon Sep 17 00:00:00 2001 From: Dan Tecuci Date: Thu, 18 Jul 2024 17:47:01 -0500 Subject: [PATCH 1/3] minor fix for LLMElementSummarizer --- lib/sycamore/sycamore/transforms/summarize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sycamore/sycamore/transforms/summarize.py b/lib/sycamore/sycamore/transforms/summarize.py index abc4a1fb5..6cec094b7 100644 --- a/lib/sycamore/sycamore/transforms/summarize.py +++ b/lib/sycamore/sycamore/transforms/summarize.py @@ -62,7 +62,7 @@ def _summarize_text_element(self, element: Element) -> Element: if element.text_representation: response = self._llm.generate(prompt_kwargs={"prompt": prompt, "query": element.text_representation}) - element.properties["summary"] = response["summary"] + element.properties["summary"] = response return element From 38b8f0a3dd18bdfef7072a4fe15bd2c966ca01a5 Mon Sep 17 00:00:00 2001 From: Dan Tecuci Date: Fri, 23 Aug 2024 18:03:46 -0500 Subject: [PATCH 2/3] fixed unit test as for test_summarize --- lib/sycamore/sycamore/tests/unit/transforms/test_summarize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sycamore/sycamore/tests/unit/transforms/test_summarize.py b/lib/sycamore/sycamore/tests/unit/transforms/test_summarize.py index e71198212..f38164c1a 100644 --- a/lib/sycamore/sycamore/tests/unit/transforms/test_summarize.py +++ b/lib/sycamore/sycamore/tests/unit/transforms/test_summarize.py @@ -34,7 +34,7 @@ def test_summarize_text_calls_llm(self, mocker): doc = text_summarizer.summarize(doc) assert doc.elements[0].properties == {} - assert doc.elements[1].properties == {"summary": "summary"} + assert doc.elements[1].properties == {"summary" : {"summary": "summary"}} def filter_elements_on_length(element: Element) -> bool: From 99c82f461326a687a7556edc1c0a055f2d180d85 Mon Sep 17 00:00:00 2001 From: Dan Tecuci Date: Fri, 23 Aug 2024 18:08:56 -0500 Subject: [PATCH 3/3] fixed unit test as for test_summarize --- lib/sycamore/sycamore/tests/unit/transforms/test_summarize.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sycamore/sycamore/tests/unit/transforms/test_summarize.py b/lib/sycamore/sycamore/tests/unit/transforms/test_summarize.py index f38164c1a..3b468e448 100644 --- a/lib/sycamore/sycamore/tests/unit/transforms/test_summarize.py +++ b/lib/sycamore/sycamore/tests/unit/transforms/test_summarize.py @@ -23,6 +23,7 @@ def test_summarize_text_calls_llm(self, mocker): llm = mocker.Mock(spec=LLM) generate = mocker.patch.object(llm, "generate") generate.return_value = {"summary": "summary"} + doc = Document() element1 = Element() element1.text_representation = "".join(random.choices(string.ascii_letters, k=10))