Execute text actions and return the next state, rewards, done flags, and additional information. Parameters: - text_actions (List[str]): A list of text actions to execute. Returns: - next_observations (Dict): - 'text' (None or List
(self, text_actions: List[str])
| 44 | return {'text': None, 'image': obs, 'anchor': None}, infos |
| 45 | |
| 46 | def step(self, text_actions: List[str]): |
| 47 | """ |
| 48 | Execute text actions and return the next state, rewards, done flags, and additional information. |
| 49 | |
| 50 | Parameters: |
| 51 | - text_actions (List[str]): A list of text actions to execute. |
| 52 | |
| 53 | Returns: |
| 54 | - next_observations (Dict): |
| 55 | - 'text' (None or List[str]): The textual observation. |
| 56 | - 'image' (np.ndarray or torch.Tensor): The image observation as either a NumPy array or a PyTorch tensor. |
| 57 | - 'anchor' (None or Any): Anchor observation without any histories or additional info. (for GiGPO only). |
| 58 | - rewards (np.ndarry or torch.Tensor): The rewards returned by the environment. |
| 59 | - dones (np.ndarray or torch.Tensor): Done flags indicating which environments have completed. |
| 60 | - infos (List[Dict]): Additional environment information. |
| 61 | |
| 62 | Exceptions: |
| 63 | - NotImplementedError: If an observation key is not in ('text', 'image'). |
| 64 | """ |
| 65 | actions, valids = self.projection_f(text_actions) |
| 66 | next_obs, rewards, dones, infos = self.envs.step(actions) |
| 67 | |
| 68 | next_observations = { |
| 69 | 'text': None, # Implement this if needed |
| 70 | 'image': next_obs, |
| 71 | 'anchor': None # For GiGPO only. anchor observation without any histories, hint, etc. Implement this if needed |
| 72 | } |
| 73 | # add action_valid to infos |
| 74 | for i, info in enumerate(infos): |
| 75 | info['is_action_valid'] = to_numpy(valids[i]) |
| 76 | |
| 77 | rewards = to_numpy(rewards) |
| 78 | dones = to_numpy(dones) |
| 79 | |
| 80 | return next_observations, rewards, dones, infos |
| 81 | |
| 82 | def build_text_obs(self,) -> List[str]: |
| 83 | """ |
no test coverage detected