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.
Files changed (35) hide show
  1. {goose_py-0.7.2 → goose_py-0.7.3}/PKG-INFO +1 -1
  2. {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/state.py +8 -1
  3. {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/task.py +9 -3
  4. {goose_py-0.7.2 → goose_py-0.7.3}/pyproject.toml +1 -1
  5. {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_state.py +11 -0
  6. {goose_py-0.7.2 → goose_py-0.7.3}/uv.lock +1 -1
  7. {goose_py-0.7.2 → goose_py-0.7.3}/.envrc +0 -0
  8. {goose_py-0.7.2 → goose_py-0.7.3}/.github/workflows/publish.yml +0 -0
  9. {goose_py-0.7.2 → goose_py-0.7.3}/.gitignore +0 -0
  10. {goose_py-0.7.2 → goose_py-0.7.3}/.python-version +0 -0
  11. {goose_py-0.7.2 → goose_py-0.7.3}/.stubs/jsonpath_ng/__init__.pyi +0 -0
  12. {goose_py-0.7.2 → goose_py-0.7.3}/.stubs/litellm/__init__.pyi +0 -0
  13. {goose_py-0.7.2 → goose_py-0.7.3}/Makefile +0 -0
  14. {goose_py-0.7.2 → goose_py-0.7.3}/README.md +0 -0
  15. {goose_py-0.7.2 → goose_py-0.7.3}/goose/__init__.py +0 -0
  16. {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/agent.py +0 -0
  17. {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/conversation.py +0 -0
  18. {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/flow.py +0 -0
  19. {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/result.py +0 -0
  20. {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/store.py +0 -0
  21. {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/types/__init__.py +0 -0
  22. {goose_py-0.7.2 → goose_py-0.7.3}/goose/_internal/types/agent.py +0 -0
  23. {goose_py-0.7.2 → goose_py-0.7.3}/goose/agent.py +0 -0
  24. {goose_py-0.7.2 → goose_py-0.7.3}/goose/errors.py +0 -0
  25. {goose_py-0.7.2 → goose_py-0.7.3}/goose/flow.py +0 -0
  26. {goose_py-0.7.2 → goose_py-0.7.3}/goose/py.typed +0 -0
  27. {goose_py-0.7.2 → goose_py-0.7.3}/goose/runs.py +0 -0
  28. {goose_py-0.7.2 → goose_py-0.7.3}/tests/__init__.py +0 -0
  29. {goose_py-0.7.2 → goose_py-0.7.3}/tests/conftest.py +0 -0
  30. {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_agent.py +0 -0
  31. {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_complex_flow_arguments.py +0 -0
  32. {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_downstream_task.py +0 -0
  33. {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_jamming.py +0 -0
  34. {goose_py-0.7.2 → goose_py-0.7.3}/tests/test_looping.py +0 -0
  35. {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.2
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 add_node_state(self, node_state: NodeState[Any], /) -> None:
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.add_node_state(node_state)
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.add_node_state(node_state)
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.add_node_state(node_state)
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:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "goose-py"
3
- version = "0.7.2"
3
+ version = "0.7.3"
4
4
  description = "A tool for AI workflows based on human-computer collaboration and structured output."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -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__"
@@ -234,7 +234,7 @@ wheels = [
234
234
 
235
235
  [[package]]
236
236
  name = "goose-py"
237
- version = "0.7.2"
237
+ version = "0.7.3"
238
238
  source = { editable = "." }
239
239
  dependencies = [
240
240
  { name = "jsonpath-ng" },
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