MCPcopy Create free account
hub / github.com/OpenManus/OpenManus-RL / step

Method step

openmanus_rl/environments/base.py:46–80  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

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 """

Callers 3

multi_turn_loopMethod · 0.45
_run_single_rolloutMethod · 0.45

Calls 1

to_numpyFunction · 0.85

Tested by

no test coverage detected