mirascope.core.gemini.tool¶
The GeminiTool
class for easy tool usage with Google's Gemini LLM calls.
Usage Documentation
GeminiTool
¶
Bases: BaseTool[Tool]
A class for defining tools for Gemini LLM calls.
Example:
from mirascope.core import prompt_template
from mirascope.core.gemini import gemini_call
def format_book(title: str, author: str) -> str:
return f"{title} by {author}"
@gemini_call("gemini-1.5-flash", tools=[format_book])
def recommend_book(genre: str) -> str:
return f"Recommend a {genre} book"
response = recommend_book("fantasy")
if tool := response.tool: # returns an `GeminiTool` instance
print(tool.call())
tool_schema
classmethod
¶
Constructs a JSON Schema tool schema from the BaseModel
schema defined.
Example:
from mirascope.core.gemini import GeminiTool
def format_book(title: str, author: str) -> str:
return f"{title} by {author}"
tool_type = GeminiTool.type_from_fn(format_book)
print(tool_type.tool_schema()) # prints the Gemini-specific tool schema
Source code in mirascope/core/gemini/tool.py
from_tool_call
classmethod
¶
from_tool_call(tool_call: FunctionCall) -> GeminiTool
Constructs an GeminiTool
instance from a tool_call
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_call |
FunctionCall
|
The Gemini tool call from which to construct this tool instance. |
required |