r"""Decorator that records the execution of a function if ToolEvent is available. Parameters: func (callable): The function to be decorated. Returns: callable: The wrapped function which records its execution details.
(func)
| 549 | |
| 550 | |
| 551 | def agentops_decorator(func): |
| 552 | r"""Decorator that records the execution of a function if ToolEvent is |
| 553 | available. |
| 554 | |
| 555 | Parameters: |
| 556 | func (callable): The function to be decorated. |
| 557 | |
| 558 | Returns: |
| 559 | callable: The wrapped function which records its execution details. |
| 560 | """ |
| 561 | |
| 562 | @wraps(func) |
| 563 | def wrapper(*args, **kwargs): |
| 564 | if ToolEvent: |
| 565 | tool_event = ToolEvent(name=func.__name__, params=kwargs) |
| 566 | result = func(*args, **kwargs) |
| 567 | tool_event.returns = result |
| 568 | record(tool_event) |
| 569 | return result |
| 570 | return func(*args, **kwargs) |
| 571 | |
| 572 | return wrapper |
| 573 | |
| 574 | |
| 575 | class AgentOpsMeta(type): |