futurehouse-client 0.4.5.dev160__py3-none-any.whl → 0.4.5.dev201__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.
@@ -2,10 +2,13 @@ from typing import Any, Generic, TypeAlias, TypeVar
2
2
 
3
3
  from aviary.message import Message
4
4
  from aviary.tools.base import Tool
5
+ from ldp.agent import Agent
5
6
  from ldp.data_structures import Transition
6
7
  from ldp.graph.ops import OpResult
7
8
  from pydantic import BaseModel, ConfigDict, Field, field_serializer
8
9
 
10
+ from .app import Step
11
+
9
12
  T = TypeVar("T")
10
13
 
11
14
 
@@ -34,10 +37,6 @@ class ASVState(BaseState, Generic[T]):
34
37
  def serialize_action(self, action: OpResult[T]) -> dict:
35
38
  return action.to_dict()
36
39
 
37
- @field_serializer("next_state")
38
- def serialize_next_state(self, state: Any) -> str:
39
- return str(state)
40
-
41
40
 
42
41
  class EnvResetState(BaseState):
43
42
  observations: list[Message] = Field()
@@ -62,6 +61,62 @@ class TransitionState(BaseState):
62
61
  }
63
62
 
64
63
 
64
+ class GlobalState(BaseState):
65
+ agent: Agent | None = None
66
+ env: Any | None = None
67
+ agent_state: Any | None = None
68
+ next_agent_state: Any | None = None
69
+ observations: list = []
70
+ action: Any | None = None
71
+ value: float = 0.0
72
+ last_step_state: Transition | None = None
73
+
74
+ def update_observations(self, obs: list[Message]) -> list[Message]:
75
+ previous_observations = self.observations or []
76
+ self.observations = obs
77
+ return previous_observations
78
+
79
+ def store_step_state(self, step_state: Transition) -> None:
80
+ self.last_step_state = step_state
81
+
82
+ def update_trajectory_data(self, **kwargs) -> None:
83
+ for key, value in kwargs.items():
84
+ setattr(self, key, value)
85
+
86
+ def _get_safe_previous_observations(
87
+ self, current_obs: list[Message] | None = None
88
+ ) -> list[Message]:
89
+ if self.last_step_state and self.last_step_state.next_observation:
90
+ return self.last_step_state.next_observation
91
+ if self.observations:
92
+ return self.observations
93
+ return current_obs or []
94
+
95
+ def create_step_state(self, callback_type: Step, **kwargs) -> Transition:
96
+ defaults = {
97
+ "timestep": getattr(self.agent, "_timestep", 0) if self.agent else 0,
98
+ "agent_state": self.agent_state,
99
+ "next_agent_state": self.next_agent_state or self.agent_state,
100
+ "observation": self._get_safe_previous_observations(),
101
+ "next_observation": self.observations or [],
102
+ "action": self.action,
103
+ "reward": 0.0,
104
+ "truncated": False,
105
+ "done": False,
106
+ "value": self.value or 0.0,
107
+ "metadata": {"callback_type": callback_type},
108
+ }
109
+
110
+ for key, value in kwargs.items():
111
+ if key == "metadata" and isinstance(value, dict):
112
+ if isinstance(defaults["metadata"], dict):
113
+ defaults["metadata"].update(value)
114
+ else:
115
+ defaults[key] = value
116
+
117
+ return Transition(**defaults)
118
+
119
+
65
120
  StateType: TypeAlias = (
66
121
  BeforeTransitionState
67
122
  | InitialState
@@ -69,4 +124,5 @@ StateType: TypeAlias = (
69
124
  | EnvResetState
70
125
  | EnvStepState
71
126
  | TransitionState
127
+ | GlobalState
72
128
  )
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.4.5.dev160'
32
- __version_tuple__ = version_tuple = (0, 4, 5, 'dev160')
31
+ __version__ = version = '0.4.5.dev201'
32
+ __version_tuple__ = version_tuple = (0, 4, 5, 'dev201')
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: futurehouse-client
3
- Version: 0.4.5.dev160
3
+ Version: 0.4.5.dev201
4
4
  Summary: A client for interacting with endpoints of the FutureHouse service.
5
5
  Author-email: FutureHouse technical staff <hello@futurehouse.org>
6
6
  License: Apache License
@@ -1,13 +1,13 @@
1
1
  futurehouse_client/__init__.py,sha256=q5cpcuPkhTaueXsySsgWpH0F-2EsRxcdJfP91ze6khU,991
2
2
  futurehouse_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- futurehouse_client/version.py,sha256=6BA6oRbUzdnpPhiNHEHGYWEa8NjSzYLRAwSlZ3RVS6Y,721
3
+ futurehouse_client/version.py,sha256=gVEi6V2NhKQOnRNh8vVkILg1cdwbsy1LGjqPIbyPeLo,721
4
4
  futurehouse_client/clients/__init__.py,sha256=-HXNj-XJ3LRO5XM6MZ709iPs29YpApss0Q2YYg1qMZw,280
5
5
  futurehouse_client/clients/data_storage_methods.py,sha256=f8ZsVicEtO50pRXoPzEB2GpiyqosNofyoW8vJeYvFnM,119266
6
6
  futurehouse_client/clients/job_client.py,sha256=b5gpzulZpxpv9R337r3UKItnMdtd6CGlI1sV3_VQJso,13985
7
7
  futurehouse_client/clients/rest_client.py,sha256=kLCR4dYduwX_16jaOZ26RGCOR2A_6nk2gpBKUqQ-KVI,110247
8
8
  futurehouse_client/models/__init__.py,sha256=N1MwDUYonsMN9NdaShsYcJspyL7H756MYj7VWFeD3fk,978
9
9
  futurehouse_client/models/app.py,sha256=UUg17I3zk6cH_7mrdojHGYvQfm_SeDkuUxsPlRyIYz0,31895
10
- futurehouse_client/models/client.py,sha256=n4HD0KStKLm6Ek9nL9ylP-bkK10yzAaD1uIDF83Qp_A,1828
10
+ futurehouse_client/models/client.py,sha256=554vp7Cr-17BTeRZtN5DhCRQesRRtr31ZPkHXUrhyCE,3835
11
11
  futurehouse_client/models/data_storage_methods.py,sha256=cpF2g4y_REECaz--WhaJeLqXA_3m3keRP5XOXiL8GOI,13811
12
12
  futurehouse_client/models/job_event.py,sha256=lMrx-lV7BQkKl419ErWZ6Q1EjurmhBFSns0z6zwGaVo,2766
13
13
  futurehouse_client/models/rest.py,sha256=SbeXZSPUCM0lQ_gVUPa64vKzMxuUVgqmJ5YThfDWs8g,4726
@@ -17,8 +17,8 @@ futurehouse_client/utils/general.py,sha256=PIkGLCSA3kUvc6mwR-prEB7YnMdKILOIm6cPo
17
17
  futurehouse_client/utils/module_utils.py,sha256=aFyd-X-pDARXz9GWpn8SSViUVYdSbuy9vSkrzcVIaGI,4955
18
18
  futurehouse_client/utils/monitoring.py,sha256=UjRlufe67kI3VxRHOd5fLtJmlCbVA2Wqwpd4uZhXkQM,8728
19
19
  futurehouse_client/utils/world_model_tools.py,sha256=v2krZGrco0ur2a_pcRMtnQL05SxlIoBXuJ5R1JkQNws,2921
20
- futurehouse_client-0.4.5.dev160.dist-info/licenses/LICENSE,sha256=oQ9ZHjUi-_6GfP3gs14FlPb0OlGwE1QCCKFGnJ4LD2I,11341
21
- futurehouse_client-0.4.5.dev160.dist-info/METADATA,sha256=ulzDMOtoPKkLAJxL6JPcqSzmuTqOmP5wxiB7l3bm_qM,27101
22
- futurehouse_client-0.4.5.dev160.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- futurehouse_client-0.4.5.dev160.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
24
- futurehouse_client-0.4.5.dev160.dist-info/RECORD,,
20
+ futurehouse_client-0.4.5.dev201.dist-info/licenses/LICENSE,sha256=oQ9ZHjUi-_6GfP3gs14FlPb0OlGwE1QCCKFGnJ4LD2I,11341
21
+ futurehouse_client-0.4.5.dev201.dist-info/METADATA,sha256=2MNiAgseBRKeAO9y03jEiq2ejMC3r87PwHvS-_DGWp8,27101
22
+ futurehouse_client-0.4.5.dev201.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ futurehouse_client-0.4.5.dev201.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
24
+ futurehouse_client-0.4.5.dev201.dist-info/RECORD,,