Execute an action
(
self,
*,
context: CopilotKitContext,
name: str,
arguments: dict,
)
| 267 | return action |
| 268 | |
| 269 | def execute_action( |
| 270 | self, |
| 271 | *, |
| 272 | context: CopilotKitContext, |
| 273 | name: str, |
| 274 | arguments: dict, |
| 275 | ) -> Coroutine[Any, Any, ActionResultDict]: |
| 276 | """ |
| 277 | Execute an action |
| 278 | """ |
| 279 | |
| 280 | action = self._get_action(context=context, name=name) |
| 281 | |
| 282 | self._log_request_info( |
| 283 | title="Handling execute action request:", |
| 284 | data=[ |
| 285 | ("Context", context), |
| 286 | ("Action", action.dict_repr()), |
| 287 | ("Arguments", arguments), |
| 288 | ], |
| 289 | ) |
| 290 | |
| 291 | try: |
| 292 | result = action.execute(arguments=arguments) |
| 293 | return result |
| 294 | except Exception as error: |
| 295 | raise ActionExecutionException(name, error) from error |
| 296 | |
| 297 | def execute_agent( # pylint: disable=too-many-arguments |
| 298 | self, |
no test coverage detected