Orchestrator
Module contains the main loops of the agent-environment interaction and replay functions.
Classes:
Functions:
-
main_loop
–Main loop of the agent-environment interaction. The agent is run on the tape, then the environment reacts to the
-
replay_tape
–Replay the tape with the agent and compare the steps with the old tape.
-
replay_tapes
–Validate the list of tapes with the agent and environment.
MainLoopStream
Bases: Generic[TapeType]
Methods:
-
get_final_tape
–Return the last tape by either the agent or the environment.
Source code in tapeagents/orchestrator.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
get_final_tape()
Return the last tape by either the agent or the environment.
Source code in tapeagents/orchestrator.py
62 63 64 65 66 67 68 69 70 71 72 |
|
main_loop(agent, start_tape, environment, max_loops=-1)
Main loop of the agent-environment interaction. The agent is run on the tape, then the environment reacts to the agent's tape, then the agent is run on the environment's tape, and so on. The loop stops when the agent emits a final step or the environment emits a final step, or the maximum number of loops is reached.
:param agent: Agent object :param start_tape: initial tape :param environment: Environment object :param max_loops: maximum number of loops, -1 for infinite
:return: generator of MainLoopEvent objects
Source code in tapeagents/orchestrator.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
replay_tape(agent, tape, env=None, start_tape=None, reuse_observations=False, stop_on_mismatch=True)
Replay the tape with the agent and compare the steps with the old tape. Count mismatches and print diffs of them.
:param agent: Agent object :param tape: Old tape object :param env: Environment object :param start_tape: initial tape, if None, the first observations of the tape are used :param reuse_observations: reuse observations from the tape instead of calling the environment :param stop_on_mismatch: stop the replay on the first mismatch
:return: True if all steps match, False otherwise
Source code in tapeagents/orchestrator.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
replay_tapes(agent, tapes, env=None, reuse_observations=False, pause_on_error=False)
Validate the list of tapes with the agent and environment. Check that the agent produce exactly the same steps as the original ones. Returns the number of failed tapes.
Source code in tapeagents/orchestrator.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|