From f059a17b17f1654f76033c2721d1d33eadc04bf3 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 25 Oct 2024 13:42:45 -0400 Subject: [PATCH] Fix griptape cloud ruleset drivers --- .../griptape_cloud_conversation_memory_driver.py | 2 +- .../test_griptape_cloud_conversation_memory_driver.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/griptape/drivers/memory/conversation/griptape_cloud_conversation_memory_driver.py b/griptape/drivers/memory/conversation/griptape_cloud_conversation_memory_driver.py index 6c1783519..afaa03b6e 100644 --- a/griptape/drivers/memory/conversation/griptape_cloud_conversation_memory_driver.py +++ b/griptape/drivers/memory/conversation/griptape_cloud_conversation_memory_driver.py @@ -128,7 +128,7 @@ def load(self) -> tuple[list[Run], dict[str, Any]]: runs = [ Run( - id=m["metadata"].pop("run_id"), + id=m["metadata"].pop("run_id", uuid.uuid4().hex), meta=m["metadata"], input=BaseArtifact.from_json(m["input"]), output=BaseArtifact.from_json(m["output"]), diff --git a/tests/unit/drivers/memory/conversation/test_griptape_cloud_conversation_memory_driver.py b/tests/unit/drivers/memory/conversation/test_griptape_cloud_conversation_memory_driver.py index 0c76d6ecd..2c376ef4d 100644 --- a/tests/unit/drivers/memory/conversation/test_griptape_cloud_conversation_memory_driver.py +++ b/tests/unit/drivers/memory/conversation/test_griptape_cloud_conversation_memory_driver.py @@ -25,7 +25,7 @@ def request(*args, **kwargs): "message_id": f"{thread_id}_message", "input": '{"type": "TextArtifact", "id": "1234", "value": "Hi There, Hello"}', "output": '{"type": "TextArtifact", "id": "123", "value": "Hello! How can I assist you today?"}', - "metadata": {"run_id": "1234"}, + "metadata": {"run_id": "1234"} if thread_id != "no_meta" else {}, } ] } @@ -118,3 +118,9 @@ def test_load(self, driver): assert len(runs) == 1 assert runs[0].id == "1234" assert metadata == {"foo": "bar"} + + def test_load_no_message_meta(self, driver): + driver.thread_id = "no_meta" + runs, metadata = driver.load() + assert len(runs) == 1 + assert metadata == {"foo": "bar"}