goose-py 0.7.1__py3-none-any.whl → 0.7.2__py3-none-any.whl

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.
@@ -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
goose/_internal/state.py CHANGED
@@ -61,6 +61,10 @@ class NodeState[ResultT: Result](BaseModel):
61
61
  self.conversation.user_messages.append(message)
62
62
  return self
63
63
 
64
+ def undo(self) -> Self:
65
+ self.conversation.undo()
66
+ return self
67
+
64
68
 
65
69
  class FlowRun:
66
70
  def __init__(self) -> None:
goose/_internal/task.py CHANGED
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: goose-py
3
- Version: 0.7.1
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
@@ -5,14 +5,14 @@ goose/flow.py,sha256=A1bzNIjnoVXRFm6LGhQglxVnKMP0vEVfvTubTol7Kww,58
5
5
  goose/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  goose/runs.py,sha256=HHcky_IbmY9HWBjpXJgOcH2Ko0N39qADsGIPR8QYpek,160
7
7
  goose/_internal/agent.py,sha256=l0pKfShovrs238sKAr-zubtcacYm82TGwQHcBWVJm2g,5875
8
- goose/_internal/conversation.py,sha256=BiWxWN2W-0fMMLgVRaVYld5_5-AttA3M5KF8JGznVwg,1081
8
+ goose/_internal/conversation.py,sha256=1OZQ_N6QZE7L_ZpXG2bjoWkVQ-G7h0JvKkqswmQWG58,1202
9
9
  goose/_internal/flow.py,sha256=KGT6NpkMY8q_N1yKwWrxfTbhwcu5AwdHtgCPqCdL3F8,3266
10
10
  goose/_internal/result.py,sha256=-eZJn-2sPo7rHZ38Sz6IAHXqiJ-Ss39esEoFGimJEBI,155
11
- goose/_internal/state.py,sha256=dKXSNMVzeM_2h0YuyMatU1I57REAzttuYBJmoUMy3ag,5703
11
+ goose/_internal/state.py,sha256=NTF9L2hrO7xXKPNNJjmOhHiXSTW5mnDULjvm81aqGLQ,5785
12
12
  goose/_internal/store.py,sha256=vIxPIpechF_lEQlQ8JT1NDySDfHe3-eMHEWeTqVbscg,946
13
- goose/_internal/task.py,sha256=cHzS7TTDXruPwXDK8P03zs3HUiJqAXECuPuAM3Oo5Tw,4685
13
+ goose/_internal/task.py,sha256=k_DuFTnaugbkFXz_xvZOrmwFV-MlKf0RZCXfR7M_6ko,4910
14
14
  goose/_internal/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  goose/_internal/types/agent.py,sha256=rNVt2gEr_m4_8tGFgcdichpPp8xhOS5GY0kN2C4tiE8,2153
16
- goose_py-0.7.1.dist-info/METADATA,sha256=b_FEa3StNuozZAxU6W_qXdEVzW98W6nLpibqcqNhh9s,441
17
- goose_py-0.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- goose_py-0.7.1.dist-info/RECORD,,
16
+ goose_py-0.7.2.dist-info/METADATA,sha256=FVAKqtk6EqumBkzOEtbFn9GA1mLiAinNF-nJ7-K6dC0,441
17
+ goose_py-0.7.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ goose_py-0.7.2.dist-info/RECORD,,