mirascope.core.groq.tool
The GroqTool class for easy tool usage with Groq LLM calls.
Usage
Class GroqTool
A class for defining tools for Groq LLM calls.
Example:
from mirascope.core import prompt_template
from mirascope.core.groq import groq_call
def format_book(title: str, author: str) -> str:
return f"{title} by {author}"
@groq_call("llama-3.1-8b-instant", 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 `GroqTool` instance
print(tool.call())Bases:
BaseToolAttributes
| Name | Type | Description |
|---|---|---|
| tool_call | SkipJsonSchema[ChatCompletionMessageToolCall] | - |
Function tool_schema
Constructs a JSON Schema tool schema from the BaseModel schema defined.
Example:
from mirascope.core.groq import GroqTool
def format_book(title: str, author: str) -> str:
return f"{title} by {author}"
tool_type = GroqTool.type_from_fn(format_book)
print(tool_type.tool_schema()) # prints the Groq-specific tool schemaParameters
| Name | Type | Description |
|---|---|---|
| cls | Any | - |
Returns
| Type | Description |
|---|---|
| ChatCompletionToolParam | - |
Function from_tool_call
Constructs an GroqTool instance from a tool_call.
Parameters
| Name | Type | Description |
|---|---|---|
| cls | Any | - |
| tool_call | ChatCompletionMessageToolCall | The Groq tool call from which to construct this tool instance. |
Returns
| Type | Description |
|---|---|
| GroqTool | - |