mirascope.core.groq.call_response_chunk¶
This module contains the GroqCallResponseChunk
class.
Usage Documentation
GroqCallResponseChunk
¶
Bases: BaseCallResponseChunk[ChatCompletionChunk, FinishReason]
A convenience wrapper around the Groq ChatCompletionChunk
streamed chunks.
When calling the Groq API using a function decorated with groq_call
and
stream
set to True
, the stream will contain GroqResponseChunk
instances with
properties that allow for more convenient 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", stream=True)
def recommend_book(genre: str) -> str:
return f"Recommend a {genre} book"
stream = recommend_book("fantasy") # response is an `GroqStream`
for chunk, _ in stream:
print(chunk.content, end="", flush=True)