goose-py 0.7.1__tar.gz → 0.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {goose_py-0.7.1 → goose_py-0.7.2}/PKG-INFO +1 -1
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/_internal/conversation.py +8 -6
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/_internal/state.py +4 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/_internal/task.py +6 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/pyproject.toml +1 -1
- {goose_py-0.7.1 → goose_py-0.7.2}/tests/test_state.py +31 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/uv.lock +1 -1
- {goose_py-0.7.1 → goose_py-0.7.2}/.envrc +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/.github/workflows/publish.yml +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/.gitignore +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/.python-version +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/.stubs/jsonpath_ng/__init__.pyi +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/.stubs/litellm/__init__.pyi +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/Makefile +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/README.md +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/__init__.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/_internal/agent.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/_internal/flow.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/_internal/result.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/_internal/store.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/_internal/types/__init__.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/_internal/types/agent.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/agent.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/errors.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/flow.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/py.typed +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/goose/runs.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/tests/__init__.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/tests/conftest.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/tests/test_agent.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/tests/test_complex_flow_arguments.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/tests/test_downstream_task.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/tests/test_jamming.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/tests/test_looping.py +0 -0
- {goose_py-0.7.1 → goose_py-0.7.2}/tests/test_regenerate.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: goose-py
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.2
|
4
4
|
Summary: A tool for AI workflows based on human-computer collaboration and structured output.
|
5
5
|
Author-email: Nash Taylor <nash@chelle.ai>, Joshua Cook <joshua@chelle.ai>, Michael Sankur <michael@chelle.ai>
|
6
6
|
Requires-Python: >=3.12
|
@@ -1,12 +1,9 @@
|
|
1
|
+
from typing import Self
|
2
|
+
|
1
3
|
from pydantic import BaseModel
|
2
4
|
|
3
5
|
from goose._internal.result import Result
|
4
|
-
from goose._internal.types.agent import
|
5
|
-
AssistantMessage,
|
6
|
-
LLMMessage,
|
7
|
-
SystemMessage,
|
8
|
-
UserMessage,
|
9
|
-
)
|
6
|
+
from goose._internal.types.agent import AssistantMessage, LLMMessage, SystemMessage, UserMessage
|
10
7
|
|
11
8
|
|
12
9
|
class Conversation[R: Result](BaseModel):
|
@@ -31,3 +28,8 @@ class Conversation[R: Result](BaseModel):
|
|
31
28
|
messages.append(AssistantMessage(text=self.result_messages[-1].model_dump_json()).render())
|
32
29
|
|
33
30
|
return messages
|
31
|
+
|
32
|
+
def undo(self) -> Self:
|
33
|
+
self.user_messages.pop()
|
34
|
+
self.result_messages.pop()
|
35
|
+
return self
|
@@ -63,6 +63,12 @@ class Task[**P, R: Result]:
|
|
63
63
|
|
64
64
|
return result
|
65
65
|
|
66
|
+
def undo(self, *, index: int = 0) -> None:
|
67
|
+
flow_run = self.__get_current_flow_run()
|
68
|
+
node_state = flow_run.get(task=self, index=index)
|
69
|
+
node_state.undo()
|
70
|
+
flow_run.add_node_state(node_state)
|
71
|
+
|
66
72
|
async def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
|
67
73
|
flow_run = self.__get_current_flow_run()
|
68
74
|
node_state = flow_run.get_next(task=self)
|
@@ -1,9 +1,12 @@
|
|
1
1
|
import random
|
2
2
|
import string
|
3
|
+
from unittest.mock import Mock
|
3
4
|
|
4
5
|
import pytest
|
6
|
+
from pytest_mock import MockerFixture
|
5
7
|
|
6
8
|
from goose import Result, flow, task
|
9
|
+
from goose._internal.types.agent import SystemMessage, TextMessagePart, UserMessage
|
7
10
|
from goose.errors import Honk
|
8
11
|
|
9
12
|
|
@@ -20,6 +23,15 @@ async def generate_random_word(*, n_characters: int) -> GeneratedWord:
|
|
20
23
|
return GeneratedWord(word="".join(random.sample(string.ascii_lowercase, n_characters)))
|
21
24
|
|
22
25
|
|
26
|
+
@pytest.fixture
|
27
|
+
def generate_random_word_adapter(mocker: MockerFixture) -> Mock:
|
28
|
+
return mocker.patch.object(
|
29
|
+
generate_random_word,
|
30
|
+
"_Task__adapt",
|
31
|
+
return_value=GeneratedWord(word="__ADAPTED__"),
|
32
|
+
)
|
33
|
+
|
34
|
+
|
23
35
|
@task
|
24
36
|
async def make_sentence(*, words: list[GeneratedWord]) -> GeneratedSentence:
|
25
37
|
return GeneratedSentence(sentence=" ".join([word.word for word in words]))
|
@@ -47,3 +59,22 @@ async def test_state_causes_caching() -> None:
|
|
47
59
|
new_random_word = new_run.get(task=generate_random_word).result.word
|
48
60
|
|
49
61
|
assert random_word == new_random_word # unchanged node is not re-generated
|
62
|
+
|
63
|
+
|
64
|
+
@pytest.mark.asyncio
|
65
|
+
@pytest.mark.usefixtures("generate_random_word_adapter")
|
66
|
+
async def test_state_undo() -> None:
|
67
|
+
async with with_state.start_run(run_id="2"):
|
68
|
+
await with_state.generate()
|
69
|
+
|
70
|
+
async with with_state.start_run(run_id="2"):
|
71
|
+
await generate_random_word.jam(
|
72
|
+
index=0,
|
73
|
+
user_message=UserMessage(parts=[TextMessagePart(text="Change it")]),
|
74
|
+
context=SystemMessage(parts=[TextMessagePart(text="Extra info")]),
|
75
|
+
)
|
76
|
+
|
77
|
+
async with with_state.start_run(run_id="2") as run:
|
78
|
+
generate_random_word.undo()
|
79
|
+
|
80
|
+
assert run.get(task=generate_random_word).result.word != "__ADAPTED__"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|