mirascope.core.base.tool¶
This module defines the base class for tools used in LLM calls.
Usage Documentation
ToolConfig
¶
Bases: TypedDict
A base class for tool configurations.
BaseTool
¶
Bases: BaseModel
A class for defining tools for LLM calls.
Example:
from mirascope.core import BaseTool
from pydantic import Field
class FormatBook(BaseTool):
"""Returns a nicely formatted book recommendation."""
title: str = Field(..., description="The title of the book.")
author: str = Field(..., description="The author of the book.")
def call(self) -> str:
return f"{self.title} by {self.author}"
call
abstractmethod
¶
type_from_fn
classmethod
¶
Returns this tool type converted from a function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn |
Callable
|
The function to convert into this tool type. |
required |
Source code in mirascope/core/base/tool.py
type_from_base_model_type
classmethod
¶
Returns this tool type converted from a given base tool type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_type |
type[BaseModel]
|
The tool type to convert into this tool type. This can be a
custom |
required |
Source code in mirascope/core/base/tool.py
type_from_base_type
classmethod
¶
Returns this tool type converted from a base type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_type |
type[BaseType]
|
The base type (e.g. |
required |
Source code in mirascope/core/base/tool.py
model_json_schema
classmethod
¶
model_json_schema(
by_alias: bool = True,
ref_template: str = DEFAULT_REF_TEMPLATE,
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchemaNoTitles,
mode: JsonSchemaMode = "validation",
) -> dict[str, Any]
Returns the generated JSON schema for the class.
Source code in mirascope/core/base/tool.py
warn_for_unsupported_configurations
classmethod
¶
Warns when a specific provider does not support provided config options.