mirascope.core.groq.call_response | Mirascope
MirascopeLilypad

mirascope.core.groq.call_response

This module contains the GroqCallResponse class.

Usage

Class GroqCallResponse

A convenience wrapper around the Groq ChatCompletion response.

When calling the Groq API using a function decorated with groq_call, the response will be an GroqCallResponse instance with properties that allow for more convenience access to commonly used attributes.

Example:

from mirascope.core import prompt_template
from mirascope.core.groq import groq_call


@groq_call("llama-3.1-8b-instant")
def recommend_book(genre: str) -> str:
    return f"Recommend a {genre} book"

response = recommend_book("fantasy")  # response is an `GroqCallResponse` instance
print(response.content)

Bases:

BaseCallResponse[ChatCompletion, GroqTool, ChatCompletionToolParam, AsyncGroqDynamicConfig | GroqDynamicConfig, ChatCompletionMessageParam, GroqCallParams, ChatCompletionUserMessageParam, GroqMessageParamConverter]

Attributes

NameTypeDescription
contentstrReturns the content of the chat completion for the 0th choice.
finish_reasonslist[str]Returns the finish reasons of the response.
modelstrReturns the name of the response model.
idstrReturns the id of the response.
usageCompletionUsage | NoneReturns the usage of the chat completion.
input_tokensint | NoneReturns the number of input tokens.
cached_tokensint | NoneReturns the number of cached tokens.
output_tokensint | NoneReturns the number of output tokens.
message_paramSerializeAsAny[ChatCompletionAssistantMessageParam]Returns the assistants's response as a message parameter.
toolslist[GroqTool] | NoneReturns any available tool calls as their `GroqTool` definition.
toolGroqTool | NoneReturns the 0th tool for the 0th choice message.
common_finish_reasonslist[FinishReason] | None-
common_message_paramBaseMessageParam-
common_user_message_paramBaseMessageParam | None-
cost_metadataCostMetadata-

Function tool_message_params

Returns the tool message parameters for tool call results.

Parameters

NameTypeDescription
clsAny-
tools_and_outputsSequence[tuple[GroqTool, str]]The sequence of tools and their outputs from which the tool message parameters should be constructed.

Returns

TypeDescription
list[ChatCompletionToolMessageParam]The list of constructed `ChatCompletionToolMessageParam` parameters.