Documentation ¶
Overview ¶
Package starlarkgemini contains a Starlark module that exposes Gemini API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Module ¶
func Module(client *gemini.Client) *starlarkstruct.Module
Module returns a Starlark module that exposes Gemini API.
This module provides a single function, generate_content, which uses the Gemini API to generate text.
It accepts four keyword arguments:
- model (str): The name of the model to use for generation.
- contents (list of strings): The text to be provided to Gemini for generation.
- system (dict, optional): System instructions to guide Gemini's response.
- unsafe (bool, optional): Disables all model safety measures.
If you pass multiple strings in contents, each odd part will be marked as sent by user, and each even part as sent by bot.
The system dictionary has a single key, text, which should contain a string representing the system instructions.
For example:
result = gemini.generate_content( model = "gemini-1.5-flash", contents = ["Once upon a time,"], system = { "text": "You are a creative story writer. Write a short story based on the provided prompt." } )
The result variable will contain a list of candidates, where each candidate is a list of generated text parts.
The system dictionary is optional and can be used to provide system instructions to guide Gemini's response.
The system dictionary has a single key, text, which should contain a string representing the system instructions.
For example, the following system instructions will tell Gemini to write a short story based on the provided prompt:
system = { "text": "You are a creative story writer. Write a short story based on the provided prompt." }
Types ¶
This section is empty.