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
| Name | Type | Description |
|---|---|---|
| content | str | Returns the content of the chat completion for the 0th choice. |
| finish_reasons | list[str] | Returns the finish reasons of the response. |
| model | str | Returns the name of the response model. |
| id | str | Returns the id of the response. |
| usage | CompletionUsage | None | Returns the usage of the chat completion. |
| input_tokens | int | None | Returns the number of input tokens. |
| cached_tokens | int | None | Returns the number of cached tokens. |
| output_tokens | int | None | Returns the number of output tokens. |
| message_param | SerializeAsAny[ChatCompletionAssistantMessageParam] | Returns the assistants's response as a message parameter. |
| tools | list[GroqTool] | None | Returns any available tool calls as their `GroqTool` definition. |
| tool | GroqTool | None | Returns the 0th tool for the 0th choice message. |
| common_finish_reasons | list[FinishReason] | None | - |
| common_message_param | BaseMessageParam | - |
| common_user_message_param | BaseMessageParam | None | - |
| cost_metadata | CostMetadata | - |
Function tool_message_params
Returns the tool message parameters for tool call results.
Parameters
Returns
| Type | Description |
|---|---|
| list[ChatCompletionToolMessageParam] | The list of constructed `ChatCompletionToolMessageParam` parameters. |