goose-py 0.7.2__tar.gz → 0.8.0__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.8.0}/PKG-INFO +1 -1
  2. {goose_py-0.7.2 → goose_py-0.8.0}/goose/_internal/state.py +8 -1
  3. {goose_py-0.7.2 → goose_py-0.8.0}/goose/_internal/task.py +10 -4
  4. {goose_py-0.7.2 → goose_py-0.8.0}/pyproject.toml +3 -2
  5. goose_py-0.7.2/tests/test_jamming.py → goose_py-0.8.0/tests/test_refining.py +1 -1
  6. {goose_py-0.7.2 → goose_py-0.8.0}/tests/test_state.py +12 -1
  7. {goose_py-0.7.2 → goose_py-0.8.0}/uv.lock +1 -1
  8. goose_py-0.7.2/tests/conftest.py +0 -10
  9. {goose_py-0.7.2 → goose_py-0.8.0}/.envrc +0 -0
  10. {goose_py-0.7.2 → goose_py-0.8.0}/.github/workflows/publish.yml +0 -0
  11. {goose_py-0.7.2 → goose_py-0.8.0}/.gitignore +0 -0
  12. {goose_py-0.7.2 → goose_py-0.8.0}/.python-version +0 -0
  13. {goose_py-0.7.2 → goose_py-0.8.0}/.stubs/jsonpath_ng/__init__.pyi +0 -0
  14. {goose_py-0.7.2 → goose_py-0.8.0}/.stubs/litellm/__init__.pyi +0 -0
  15. {goose_py-0.7.2 → goose_py-0.8.0}/Makefile +0 -0
  16. {goose_py-0.7.2 → goose_py-0.8.0}/README.md +0 -0
  17. {goose_py-0.7.2 → goose_py-0.8.0}/goose/__init__.py +0 -0
  18. {goose_py-0.7.2 → goose_py-0.8.0}/goose/_internal/agent.py +0 -0
  19. {goose_py-0.7.2 → goose_py-0.8.0}/goose/_internal/conversation.py +0 -0
  20. {goose_py-0.7.2 → goose_py-0.8.0}/goose/_internal/flow.py +0 -0
  21. {goose_py-0.7.2 → goose_py-0.8.0}/goose/_internal/result.py +0 -0
  22. {goose_py-0.7.2 → goose_py-0.8.0}/goose/_internal/store.py +0 -0
  23. {goose_py-0.7.2 → goose_py-0.8.0}/goose/_internal/types/__init__.py +0 -0
  24. {goose_py-0.7.2 → goose_py-0.8.0}/goose/_internal/types/agent.py +0 -0
  25. {goose_py-0.7.2 → goose_py-0.8.0}/goose/agent.py +0 -0
  26. {goose_py-0.7.2 → goose_py-0.8.0}/goose/errors.py +0 -0
  27. {goose_py-0.7.2 → goose_py-0.8.0}/goose/flow.py +0 -0
  28. {goose_py-0.7.2 → goose_py-0.8.0}/goose/py.typed +0 -0
  29. {goose_py-0.7.2 → goose_py-0.8.0}/goose/runs.py +0 -0
  30. {goose_py-0.7.2 → goose_py-0.8.0}/tests/__init__.py +0 -0
  31. {goose_py-0.7.2 → goose_py-0.8.0}/tests/test_agent.py +0 -0
  32. {goose_py-0.7.2 → goose_py-0.8.0}/tests/test_complex_flow_arguments.py +0 -0
  33. {goose_py-0.7.2 → goose_py-0.8.0}/tests/test_downstream_task.py +0 -0
  34. {goose_py-0.7.2 → goose_py-0.8.0}/tests/test_looping.py +0 -0
  35. {goose_py-0.7.2 → goose_py-0.8.0}/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.8.0
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
 
@@ -43,7 +43,7 @@ class Task[**P, R: Result]:
43
43
  else:
44
44
  return state.result
45
45
 
46
- async def jam(
46
+ async def refine(
47
47
  self,
48
48
  *,
49
49
  user_message: UserMessage,
@@ -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.8.0"
4
4
  description = "A tool for AI workflows based on human-computer collaboration and structured output."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -75,7 +75,8 @@ filterwarnings = [
75
75
  "ignore::SyntaxWarning",
76
76
  "ignore::UserWarning",
77
77
  ]
78
- addopts = "-v"
79
78
  testpaths = ["tests"]
80
79
  pythonpath = ["."]
81
80
  python_files = "test_*.py"
81
+ asyncio_default_fixture_loop_scope = "session"
82
+ asyncio_mode = "auto"
@@ -53,7 +53,7 @@ async def test_jamming() -> None:
53
53
 
54
54
  # imagine this is a new process
55
55
  async with sentence.start_run(run_id="1") as second_run:
56
- await generate_random_word.jam(
56
+ await generate_random_word.refine(
57
57
  index=1,
58
58
  user_message=UserMessage(parts=[TextMessagePart(text="Change it")]),
59
59
  context=SystemMessage(parts=[TextMessagePart(text="Extra info")]),
@@ -68,7 +68,7 @@ async def test_state_undo() -> None:
68
68
  await with_state.generate()
69
69
 
70
70
  async with with_state.start_run(run_id="2"):
71
- await generate_random_word.jam(
71
+ await generate_random_word.refine(
72
72
  index=0,
73
73
  user_message=UserMessage(parts=[TextMessagePart(text="Change it")]),
74
74
  context=SystemMessage(parts=[TextMessagePart(text="Extra info")]),
@@ -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.8.0"
238
238
  source = { editable = "." }
239
239
  dependencies = [
240
240
  { name = "jsonpath-ng" },
@@ -1,10 +0,0 @@
1
- import asyncio
2
-
3
- import pytest
4
-
5
-
6
- @pytest.fixture(scope="session")
7
- def event_loop():
8
- loop = asyncio.get_event_loop()
9
- yield loop
10
- loop.close()
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