goose-py 0.9.1__py3-none-any.whl → 0.9.4__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.
goose/_internal/flow.py CHANGED
@@ -30,13 +30,13 @@ class Flow[FlowArgumentsT: FlowArguments]:
30
30
  /,
31
31
  *,
32
32
  name: str | None = None,
33
- store: IFlowRunStore[FlowArgumentsT] | None = None,
33
+ store: IFlowRunStore | None = None,
34
34
  agent_logger: IAgentLogger | None = None,
35
35
  ) -> None:
36
36
  self._fn = fn
37
37
  self._name = name
38
38
  self._agent_logger = agent_logger
39
- self._store = store or InMemoryFlowRunStore(flow_name=self.name, flow_arguments_model=self.flow_arguments_model)
39
+ self._store = store or InMemoryFlowRunStore(flow_name=self.name)
40
40
 
41
41
  @property
42
42
  def flow_arguments_model(self) -> type[FlowArgumentsT]:
@@ -59,18 +59,20 @@ class Flow[FlowArgumentsT: FlowArguments]:
59
59
 
60
60
  @asynccontextmanager
61
61
  async def start_run(self, *, run_id: str) -> AsyncIterator[FlowRun[FlowArgumentsT]]:
62
- existing_run = await self._store.get(run_id=run_id)
63
- if existing_run is None:
64
- run = FlowRun(flow_arguments_model=self.flow_arguments_model)
62
+ existing_serialized_run = await self._store.get(run_id=run_id)
63
+ if existing_serialized_run is not None:
64
+ run = FlowRun.load(
65
+ serialized_flow_run=existing_serialized_run, flow_arguments_model=self.flow_arguments_model
66
+ )
65
67
  else:
66
- run = existing_run
68
+ run = FlowRun(flow_arguments_model=self.flow_arguments_model)
67
69
 
68
70
  old_run = get_current_flow_run()
69
71
  set_current_flow_run(run)
70
72
 
71
73
  run.start(flow_name=self.name, run_id=run_id, agent_logger=self._agent_logger)
72
74
  yield run
73
- await self._store.save(run=run)
75
+ await self._store.save(run_id=run_id, run=run.dump())
74
76
  run.end()
75
77
 
76
78
  set_current_flow_run(old_run)
@@ -97,7 +99,7 @@ def flow[FlowArgumentsT: FlowArguments](fn: IGenerator[FlowArgumentsT], /) -> Fl
97
99
  def flow[FlowArgumentsT: FlowArguments](
98
100
  *,
99
101
  name: str | None = None,
100
- store: IFlowRunStore[FlowArgumentsT] | None = None,
102
+ store: IFlowRunStore | None = None,
101
103
  agent_logger: IAgentLogger | None = None,
102
104
  ) -> Callable[[IGenerator[FlowArgumentsT]], Flow[FlowArgumentsT]]: ...
103
105
  def flow[FlowArgumentsT: FlowArguments](
@@ -105,7 +107,7 @@ def flow[FlowArgumentsT: FlowArguments](
105
107
  /,
106
108
  *,
107
109
  name: str | None = None,
108
- store: IFlowRunStore[FlowArgumentsT] | None = None,
110
+ store: IFlowRunStore | None = None,
109
111
  agent_logger: IAgentLogger | None = None,
110
112
  ) -> Flow[FlowArgumentsT] | Callable[[IGenerator[FlowArgumentsT]], Flow[FlowArgumentsT]]:
111
113
  if fn is None:
goose/_internal/state.py CHANGED
@@ -166,7 +166,9 @@ class FlowRun[FlowArgumentsT: FlowArguments]:
166
166
  )
167
167
 
168
168
  @classmethod
169
- def load(cls, *, serialized_flow_run: SerializedFlowRun, flow_arguments_model: type[FlowArgumentsT]) -> Self:
169
+ def load[T: FlowArguments](
170
+ cls, *, serialized_flow_run: SerializedFlowRun, flow_arguments_model: type[T]
171
+ ) -> "FlowRun[T]":
170
172
  flow_run_state = json.loads(serialized_flow_run)
171
173
  raw_node_states = flow_run_state["node_states"]
172
174
  node_states: dict[tuple[str, int], str] = {}
@@ -175,7 +177,7 @@ class FlowRun[FlowArgumentsT: FlowArguments]:
175
177
  node_states[(task_name, int(index))] = value
176
178
  flow_arguments = flow_arguments_model.model_validate(flow_run_state["flow_arguments"])
177
179
 
178
- flow_run = cls(flow_arguments_model=flow_arguments_model)
180
+ flow_run = FlowRun(flow_arguments_model=flow_arguments_model)
179
181
  flow_run._node_states = node_states
180
182
  flow_run._flow_arguments = flow_arguments
181
183
 
goose/_internal/store.py CHANGED
@@ -2,32 +2,26 @@ from __future__ import annotations
2
2
 
3
3
  from typing import Protocol
4
4
 
5
- from goose._internal.flow import FlowRun
6
- from goose._internal.state import FlowArguments, SerializedFlowRun
5
+ from goose._internal.state import SerializedFlowRun
7
6
 
8
7
 
9
- class IFlowRunStore[FlowArgumentsT: FlowArguments](Protocol):
8
+ class IFlowRunStore(Protocol):
10
9
  def __init__(self, *, flow_name: str) -> None: ...
11
- async def get(self, *, run_id: str) -> FlowRun[FlowArgumentsT] | None: ...
12
- async def save(self, *, run: FlowRun[FlowArgumentsT]) -> None: ...
10
+ async def get(self, *, run_id: str) -> SerializedFlowRun | None: ...
11
+ async def save(self, *, run_id: str, run: SerializedFlowRun) -> None: ...
13
12
  async def delete(self, *, run_id: str) -> None: ...
14
13
 
15
14
 
16
- class InMemoryFlowRunStore[FlowArgumentsT: FlowArguments](IFlowRunStore[FlowArgumentsT]):
17
- def __init__(self, *, flow_name: str, flow_arguments_model: type[FlowArgumentsT]) -> None:
15
+ class InMemoryFlowRunStore(IFlowRunStore):
16
+ def __init__(self, *, flow_name: str) -> None:
18
17
  self._flow_name = flow_name
19
- self._flow_arguments_model = flow_arguments_model
20
18
  self._runs: dict[str, SerializedFlowRun] = {}
21
19
 
22
- async def get(self, *, run_id: str) -> FlowRun[FlowArgumentsT] | None:
23
- serialized_flow_run = self._runs.get(run_id)
24
- if serialized_flow_run is not None:
25
- return FlowRun.load(
26
- serialized_flow_run=serialized_flow_run, flow_arguments_model=self._flow_arguments_model
27
- )
20
+ async def get(self, *, run_id: str) -> SerializedFlowRun | None:
21
+ return self._runs.get(run_id)
28
22
 
29
- async def save(self, *, run: FlowRun[FlowArgumentsT]) -> None:
30
- self._runs[run.id] = run.dump()
23
+ async def save(self, *, run_id: str, run: SerializedFlowRun) -> None:
24
+ self._runs[run_id] = run
31
25
 
32
26
  async def delete(self, *, run_id: str) -> None:
33
27
  self._runs.pop(run_id, None)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: goose-py
3
- Version: 0.9.1
3
+ Version: 0.9.4
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
@@ -6,13 +6,13 @@ goose/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  goose/runs.py,sha256=kAHw08ayGbwzSH_p-CfsQDvTcA4H09nUuq6zt3gIFxo,170
7
7
  goose/_internal/agent.py,sha256=l0pKfShovrs238sKAr-zubtcacYm82TGwQHcBWVJm2g,5875
8
8
  goose/_internal/conversation.py,sha256=1OZQ_N6QZE7L_ZpXG2bjoWkVQ-G7h0JvKkqswmQWG58,1202
9
- goose/_internal/flow.py,sha256=LX6fdDBBgGNPfpSIUFenJ8-EI6tnNRuGZfUpvSb1isg,4128
9
+ goose/_internal/flow.py,sha256=05U2f5i8ofQWDjghhomwuuEPMk-ftzXn7BVl_s7pIf8,4203
10
10
  goose/_internal/result.py,sha256=-eZJn-2sPo7rHZ38Sz6IAHXqiJ-Ss39esEoFGimJEBI,155
11
- goose/_internal/state.py,sha256=wJdXHGw_KPqc1Tuv8cHj1loqLct_KHWBNXzbjBv6GAo,6552
12
- goose/_internal/store.py,sha256=ZdQwYRe1PKkTUd58p0ja1KyyGhEYGVP4gWvYsqOEWuk,1356
11
+ goose/_internal/state.py,sha256=LmMxhr3OrilYRHRxw1xYnl_dUkndaayLej83ccjfOGs,6583
12
+ goose/_internal/store.py,sha256=GMW0wBpxESmRBLfL_lFKEi9x2P6Wd6-gZ7AWjWBTUmA,904
13
13
  goose/_internal/task.py,sha256=vfmWfxhr76nSF7STMZISFqP9ugt3BkHzraMbEZKuozI,5196
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.9.1.dist-info/METADATA,sha256=O2kYoXBBpkOUDX1ejc8dBUHv6GI86trC-QTb11HoSAs,441
17
- goose_py-0.9.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- goose_py-0.9.1.dist-info/RECORD,,
16
+ goose_py-0.9.4.dist-info/METADATA,sha256=awELFF40wuVHwy9Xl76Aaku36uLX2sxxFUOMbxwiN7c,441
17
+ goose_py-0.9.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ goose_py-0.9.4.dist-info/RECORD,,