Decorators

Contents

Decorators#

Public decorators for extending or integrating with the framework.

This module contains decorators that are part of the public API and intended for end users to apply to their own functions or classes.

contextgem.public.decorators.register_tool(func, /)[source]#

Registers a function as a tool handler for LLM chat with tools.

Validates that the function has an inspectable signature and accepts keyword arguments (no positional-only parameters). Marks the function so the runtime can recognize and call it by name.

Parameters:

func (ToolHandler) – A callable to be used as a tool handler.

Returns:

The same function, marked as a registered tool.

Return type:

ToolHandler

Raises:
  • TypeError – If the provided object is not callable.

  • ValueError – If the signature cannot be inspected or has positional-only parameters, or if the function name is empty.