From b98d1d9f377f0484c427e98bee3955ac42b16e35 Mon Sep 17 00:00:00 2001 From: Luke Alvoeiro Date: Mon, 2 Sep 2024 20:40:02 -0700 Subject: [PATCH] feat: upgrade `ai-exchange` to version `0.8.3` and fix tests (#34) --- pyproject.toml | 4 ++-- src/goose/utils/ask.py | 6 +++--- tests/utils/test_ask.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 11b7b532a..df1202451 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,14 @@ [project] name = "goose-ai" description = "a programming agent that runs on your machine" -version = "0.8.3" +version = "0.8.4" readme = "README.md" requires-python = ">=3.10" dependencies = [ "attrs>=23.2.0", "rich>=13.7.1", "ruamel-yaml>=0.18.6", - "ai-exchange>=0.8.2", + "ai-exchange>=0.8.3", "click>=8.1.7", "prompt-toolkit>=3.0.47", ] diff --git a/src/goose/utils/ask.py b/src/goose/utils/ask.py index e3c057a23..0e34b444a 100644 --- a/src/goose/utils/ask.py +++ b/src/goose/utils/ask.py @@ -1,4 +1,4 @@ -from exchange import Exchange, Message +from exchange import Exchange, Message, CheckpointData def ask_an_ai(input: str, exchange: Exchange, prompt: str = "", no_history: bool = True) -> Message: @@ -61,9 +61,9 @@ def clear_exchange(exchange: Exchange, clear_tools: bool = False) -> Exchange: """ if clear_tools: - new_exchange = exchange.replace(messages=[], checkpoints=[], tools=()) + new_exchange = exchange.replace(messages=[], checkpoint_data=CheckpointData(), tools=()) else: - new_exchange = exchange.replace(messages=[], checkpoints=[]) + new_exchange = exchange.replace(messages=[], checkpoint_data=CheckpointData()) return new_exchange diff --git a/tests/utils/test_ask.py b/tests/utils/test_ask.py index 419f3a5b8..b7bd8269e 100644 --- a/tests/utils/test_ask.py +++ b/tests/utils/test_ask.py @@ -1,7 +1,7 @@ from unittest.mock import MagicMock, patch import pytest -from exchange import Exchange +from exchange import Exchange, CheckpointData from goose.utils.ask import ask_an_ai, clear_exchange, replace_prompt @@ -76,7 +76,7 @@ def test_clear_exchange_without_tools(): new_exchange = clear_exchange(exchange, clear_tools=False) # Assert - exchange.replace.assert_called_once_with(messages=[], checkpoints=[]) + exchange.replace.assert_called_once_with(messages=[], checkpoint_data=CheckpointData()) assert new_exchange == exchange.replace.return_value, "Should return the modified exchange" @@ -89,7 +89,7 @@ def test_clear_exchange_with_tools(): new_exchange = clear_exchange(exchange, clear_tools=True) # Assert - exchange.replace.assert_called_once_with(messages=[], checkpoints=[], tools=()) + exchange.replace.assert_called_once_with(messages=[], checkpoint_data=CheckpointData(), tools=()) assert new_exchange == exchange.replace.return_value, "Should return the modified exchange with tools cleared"