goose-py 0.7.2__tar.gz → 0.7.3__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.2 → goose_py-0.7.3}/PKG-INFO +1 -1
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/state.py +8 -1
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/task.py +9 -3
- {goose_py-0.7.2 → goose_py-0.7.3}/pyproject.toml +1 -1
- {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_state.py +11 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/uv.lock +1 -1
- {goose_py-0.7.2 → goose_py-0.7.3}/.envrc +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/.github/workflows/publish.yml +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/.gitignore +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/.python-version +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/.stubs/jsonpath_ng/__init__.pyi +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/.stubs/litellm/__init__.pyi +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/Makefile +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/README.md +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/__init__.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/agent.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/conversation.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/flow.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/result.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/store.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/types/__init__.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/types/agent.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/agent.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/errors.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/flow.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/py.typed +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/goose/runs.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/tests/__init__.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/tests/conftest.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_agent.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_complex_flow_arguments.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_downstream_task.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_jamming.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_looping.py +0 -0
- {goose_py-0.7.2 → goose_py-0.7.3}/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.3
|
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
|
@@ -61,6 +61,13 @@ class NodeState[ResultT: Result](BaseModel):
|
|
61
61
|
self.conversation.user_messages.append(message)
|
62
62
|
return self
|
63
63
|
|
64
|
+
def edit_last_result(self, *, result: ResultT) -> Self:
|
65
|
+
if len(self.conversation.result_messages) == 0:
|
66
|
+
raise Honk("Node awaiting response, has no result")
|
67
|
+
|
68
|
+
self.conversation.result_messages[-1] = result
|
69
|
+
return self
|
70
|
+
|
64
71
|
def undo(self) -> Self:
|
65
72
|
self.conversation.undo()
|
66
73
|
return self
|
@@ -119,7 +126,7 @@ class FlowRun:
|
|
119
126
|
self._flow_args = args
|
120
127
|
self._flow_kwargs = kwargs
|
121
128
|
|
122
|
-
def
|
129
|
+
def upsert_node_state(self, node_state: NodeState[Any], /) -> None:
|
123
130
|
key = (node_state.task_name, node_state.index)
|
124
131
|
self._node_states[key] = node_state.model_dump_json()
|
125
132
|
|
@@ -59,21 +59,27 @@ class Task[**P, R: Result]:
|
|
59
59
|
|
60
60
|
result = await self.__adapt(conversation=node_state.conversation, agent=flow_run.agent)
|
61
61
|
node_state.add_result(result=result)
|
62
|
-
flow_run.
|
62
|
+
flow_run.upsert_node_state(node_state)
|
63
63
|
|
64
64
|
return result
|
65
65
|
|
66
|
+
def edit(self, *, result: R, 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.edit_last_result(result=result)
|
70
|
+
flow_run.upsert_node_state(node_state)
|
71
|
+
|
66
72
|
def undo(self, *, index: int = 0) -> None:
|
67
73
|
flow_run = self.__get_current_flow_run()
|
68
74
|
node_state = flow_run.get(task=self, index=index)
|
69
75
|
node_state.undo()
|
70
|
-
flow_run.
|
76
|
+
flow_run.upsert_node_state(node_state)
|
71
77
|
|
72
78
|
async def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
|
73
79
|
flow_run = self.__get_current_flow_run()
|
74
80
|
node_state = flow_run.get_next(task=self)
|
75
81
|
result = await self.generate(node_state, *args, **kwargs)
|
76
|
-
flow_run.
|
82
|
+
flow_run.upsert_node_state(node_state)
|
77
83
|
return result
|
78
84
|
|
79
85
|
async def __adapt(self, *, conversation: Conversation[R], agent: Agent) -> R:
|
@@ -78,3 +78,14 @@ async def test_state_undo() -> None:
|
|
78
78
|
generate_random_word.undo()
|
79
79
|
|
80
80
|
assert run.get(task=generate_random_word).result.word != "__ADAPTED__"
|
81
|
+
|
82
|
+
|
83
|
+
@pytest.mark.asyncio
|
84
|
+
async def test_state_edit() -> None:
|
85
|
+
async with with_state.start_run(run_id="3"):
|
86
|
+
await with_state.generate()
|
87
|
+
|
88
|
+
async with with_state.start_run(run_id="3") as run:
|
89
|
+
generate_random_word.edit(result=GeneratedWord(word="__EDITED__"), index=0)
|
90
|
+
|
91
|
+
assert run.get(task=generate_random_word).result.word == "__EDITED__"
|
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
|
File without changes
|