mirascope.core.mistral.tool | Mirascope
MirascopeLilypad

mirascope.core.mistral.tool

The MistralTool class for easy tool usage with Mistral LLM calls.

Usage

Class MistralTool

A class for defining tools for Mistral LLM calls.

Example:

from mirascope.core import prompt_template
from mirascope.core.mistral import mistral_call


def format_book(title: str, author: str) -> str:
    return f"{title} by {author}"


@mistral_call("mistral-large-latest", tools=[format_book])
def recommend_book(genre: str) -> str:
    return f"Recommend a {genre} book"

response = recommend_book("fantasy")
if tool := response.tool:  # returns a `MistralTool` instance
    print(tool.call())

Bases:

BaseTool

Attributes

NameTypeDescription
tool_callSkipJsonSchema[ToolCall]-

Function tool_schema

Constructs a JSON Schema tool schema from the BaseModel schema defined.

Example:

from mirascope.core.mistral import MistralTool


def format_book(title: str, author: str) -> str:
    return f"{title} by {author}"


tool_type = MistralTool.type_from_fn(format_book)
print(tool_type.tool_schema())  # prints the Mistral-specific tool schema

Parameters

NameTypeDescription
clsAny-

Returns

TypeDescription
dict[str, Any]-

Function from_tool_call

Constructs an MistralTool instance from a tool_call.

Parameters

NameTypeDescription
clsAny-
tool_callToolCallThe Mistral tool call from which to construct this tool instance.

Returns

TypeDescription
MistralTool-