gemini.types¶
Types for interacting with Google's Gemini models using Mirascope.
GeminiCallParams
¶
Bases: BaseCallParams[GeminiTool]
The parameters to use when calling the Gemini API calls.
Example:
from mirascope.gemini import GeminiCall, GeminiCallParams
class BookRecommendation(GeminiPrompt):
prompt_template = "Please recommend a {genre} book"
genre: str
call_params = GeminiCallParams(
model="gemini-1.0-pro-001",
generation_config={"candidate_count": 2},
)
response = BookRecommender(genre="fantasy").call()
print(response.content)
#> The Name of the Wind
Source code in mirascope/gemini/types.py
GeminiCallResponse
¶
Bases: BaseCallResponse[Union[GenerateContentResponse, AsyncGenerateContentResponse], GeminiTool]
Convenience wrapper around Gemini's GenerateContentResponse
.
When using Mirascope's convenience wrappers to interact with Gemini models via
GeminiCall
, responses using GeminiCall.call()
will return a
GeminiCallResponse
, whereby the implemented properties allow for simpler syntax
and a convenient developer experience.
Example:
from mirascope.gemini import GeminiPrompt
class BookRecommender(GeminiPrompt):
prompt_template = "Please recommend a {genre} book"
genre: str
response = BookRecommender(genre="fantasy").call()
print(response.content)
#> The Lord of the Rings
Source code in mirascope/gemini/types.py
content: str
property
¶
Returns the contained string content for the 0th choice.
tool: Optional[GeminiTool]
property
¶
Returns the 0th tool for the 0th candidate's 0th content part.
Raises:
Type | Description |
---|---|
ValidationError
|
if the tool call doesn't match the tool's schema. |
tools: Optional[list[GeminiTool]]
property
¶
Returns the list of tools for the 0th candidate's 0th content part.
dump()
¶
Dumps the response to a dictionary.
GeminiCallResponseChunk
¶
Bases: BaseCallResponseChunk[GenerateContentResponse, GeminiTool]
Convenience wrapper around chat completion streaming chunks.
When using Mirascope's convenience wrappers to interact with Gemini models via
GeminiCall
, responses using GeminiCall.stream()
will return a
GeminiCallResponseChunk
, whereby the implemented properties allow for simpler
syntax and a convenient developer experience.
Example:
from mirascope.gemini import GeminiCall
class BookRecommender(GeminiCall):
prompt_template = "Please recommend a {genre} book"
genre: str
for chunk in BookRecommender(genre="science fiction").stream():
print(chunk)
#> D
# u
#
# ne
#
# by F
# r
# an
# k
# .
Source code in mirascope/gemini/types.py
content: str
property
¶
Returns the chunk content for the 0th choice.