Write & ship code
Generate Function Schemas for LLM Calls
Abstracts Python functions into callable tools for OpenAI chat models, automating schema generation and enabling LLM function execution.
Without it
Piece it together by hand, every time.
With it
Enable Large Language Models (LLMs) to reliably call external functions by automatically generating structured tool schemas from Python function signatures and docstrings.
What you get
- Parse tool schemas from Python function definitions.
- Optionally override default schemas with custom OpenAI tool schemas.
- Synthesize schemas using an LLM when validation fails.
- Enable synthesis of function output based on execution results.
Add this skill
An abstraction of a function that OpenAI chat models can call. See
https://platform.openai.com/docs/api-reference/chat/create.
By default, the tool schema will be parsed from the func, or you can
provide a user-defined tool schema to override.
Args:
func (Callable): The function to call. The tool schema is parsed from
the function signature and docstring by default.
openai_tool_schema (Optional[Dict[str, Any]], optional): A
user-defined OpenAI tool schema to override the default result.
(default: :obj:None)
synthesize_schema (Optional[bool], optional): Whether to enable the
use of a schema assistant model to automatically synthesize the
schema if validation fails or no valid schema is provided.
(default: :obj:False)
synthesize_schema_model (Optional[BaseModelBackend], optional): An
assistant model (e.g., an LLM model) used to synthesize the schema
if synthesize_schema is enabled and no valid schema is
provided. (default: :obj:None)
synthesize_schema_max_retries (int, optional): The maximum
number of attempts to retry schema synthesis using the schema
assistant model if the previous attempts fail. (default: 2)
synthesize_output (Optional[bool], optional): Flag for enabling
synthesis output mode, where output is synthesized based on the
function's execution. (default: :obj:False)
synthesize_output_model (Optional[BaseModelBackend], optional):
Model used for output synthesis in synthesis mode.
(default: :obj:None)
synthesize_output_format (Optional[Type[BaseModel]], optional): Format
for the response when synthesizing output. (default: :obj:None)