Finds a corresponding list of objects in the environment. Keyed via `tool_name` and `name`. See the base class description for more information on how the environment is keyed. Args: tool_name (str): The name of the tool called that the result belongs to.
(self, tool_name: str, name: str, index: int | None = None)
| 278 | } |
| 279 | |
| 280 | def find(self, tool_name: str, name: str, index: int | None = None): |
| 281 | """ |
| 282 | Finds a corresponding list of objects in the environment. |
| 283 | Keyed via `tool_name` and `name`. See the base class description for more information on how the environment is keyed. |
| 284 | |
| 285 | Args: |
| 286 | tool_name (str): The name of the tool called that the result belongs to. |
| 287 | name (str): The name of the result. |
| 288 | index (int | None): The index of the object to find. |
| 289 | If `None`, the entire list corresponding to `tool_name`/`name` is returned. |
| 290 | If an integer, the object at the given index is returned. |
| 291 | |
| 292 | Returns: |
| 293 | (list[dict]): if `index` is `None` - The list of objects for the given `tool_name` and `name`. |
| 294 | (dict): if `index` is an integer - The object at the given `index` for the given `tool_name` and `name`. |
| 295 | (None): If the `tool_name` or `name` is not found in the environment. |
| 296 | """ |
| 297 | |
| 298 | if tool_name not in self.environment: |
| 299 | return None |
| 300 | if name not in self.environment[tool_name]: |
| 301 | return None |
| 302 | |
| 303 | if index is None: |
| 304 | return self.environment[tool_name][name] |
| 305 | else: |
| 306 | return self.environment[tool_name][name][index] |
| 307 | |
| 308 | def to_json(self, remove_unserialisable: bool = False): |
| 309 | """ |
no outgoing calls