Documentation
¶
Index ¶
- Variables
- func GoogleAIEmbedder(g *genkit.Genkit, name string) ai.Embedder
- func GoogleAIModel(g *genkit.Genkit, name string) ai.Model
- func GoogleAIModelRef(name string, config *GeminiConfig) ai.ModelRef
- func HasCodeExecution(msg *ai.Message) bool
- func NewCodeExecutionResultPart(outcome string, output string) *ai.Part
- func NewExecutableCodePart(language string, code string) *ai.Part
- func VertexAIEmbedder(g *genkit.Genkit, name string) ai.Embedder
- func VertexAIModel(g *genkit.Genkit, name string) ai.Model
- func VertexAIModelRef(name string, config *GeminiConfig) ai.ModelRef
- type CodeExecutionResult
- type EmbedOptions
- type ExecutableCode
- type GeminiConfig
- type GoogleAI
- func (ga *GoogleAI) DefineEmbedder(g *genkit.Genkit, name string) (ai.Embedder, error)
- func (ga *GoogleAI) DefineModel(g *genkit.Genkit, name string, info *ai.ModelInfo) (ai.Model, error)
- func (ga *GoogleAI) Init(ctx context.Context, g *genkit.Genkit) (err error)
- func (ga *GoogleAI) IsDefinedEmbedder(g *genkit.Genkit, name string) bool
- func (ga *GoogleAI) Name() string
- type HarmBlockMethod
- type HarmBlockThreshold
- type HarmCategory
- type Modality
- type SafetySetting
- type ThinkingConfig
- type VertexAI
- func (v *VertexAI) DefineEmbedder(g *genkit.Genkit, name string) (ai.Embedder, error)
- func (v *VertexAI) DefineModel(g *genkit.Genkit, name string, info *ai.ModelInfo) (ai.Model, error)
- func (v *VertexAI) Init(ctx context.Context, g *genkit.Genkit) (err error)
- func (v *VertexAI) IsDefinedEmbedder(g *genkit.Genkit, name string) bool
- func (v *VertexAI) Name() string
Constants ¶
This section is empty.
Variables ¶
var ( // BasicText describes model capabilities for text-only Gemini models. BasicText = ai.ModelSupports{ Multiturn: true, Tools: true, ToolChoice: true, SystemRole: true, Media: false, } // Multimodal describes model capabilities for multimodal Gemini models. Multimodal = ai.ModelSupports{ Multiturn: true, Tools: true, ToolChoice: true, SystemRole: true, Media: true, Constrained: ai.ConstrainedSupportNoTools, } )
Functions ¶
func GoogleAIEmbedder ¶
GoogleAIEmbedder returns the ai.Embedder with the given name. It returns nil if the embedder was not defined.
func GoogleAIModel ¶
GoogleAIModel returns the ai.Model with the given name. It returns nil if the model was not defined.
func GoogleAIModelRef ¶ added in v0.5.0
func GoogleAIModelRef(name string, config *GeminiConfig) ai.ModelRef
GoogleAIModelRef creates a new ModelRef for a Google AI model with the given name and configuration.
func HasCodeExecution ¶ added in v0.5.1
HasCodeExecution checks if a message contains code execution results or executable code.
func NewCodeExecutionResultPart ¶ added in v0.5.1
NewCodeExecutionResultPart returns a Part containing the result of code execution.
func NewExecutableCodePart ¶ added in v0.5.1
NewExecutableCodePart returns a Part containing executable code.
func VertexAIEmbedder ¶
VertexAIEmbedder returns the ai.Embedder with the given name. It returns nil if the embedder was not defined.
func VertexAIModel ¶
VertexAIModel returns the ai.Model with the given name. It returns nil if the model was not defined.
func VertexAIModelRef ¶ added in v0.5.0
func VertexAIModelRef(name string, config *GeminiConfig) ai.ModelRef
VertexAIModelRef creates a new ModelRef for a Vertex AI model with the given name and configuration.
Types ¶
type CodeExecutionResult ¶ added in v0.5.1
CodeExecutionResult represents the result of a code execution.
func GetCodeExecutionResult ¶ added in v0.5.1
func GetCodeExecutionResult(msg *ai.Message) *CodeExecutionResult
GetCodeExecutionResult returns the first code execution result from a message. Returns nil if the message doesn't contain a code execution result.
func ToCodeExecutionResult ¶ added in v0.5.1
func ToCodeExecutionResult(part *ai.Part) *CodeExecutionResult
ToCodeExecutionResult tries to convert an ai.Part to a CodeExecutionResult. Returns nil if the part doesn't contain code execution results.
type EmbedOptions ¶ added in v0.5.0
type EmbedOptions struct { // Document title. Title string `json:"title,omitempty"` // Task type: RETRIEVAL_QUERY, RETRIEVAL_DOCUMENT, and so forth. // See the Vertex AI text embedding docs. TaskType string `json:"task_type,omitempty"` }
EmbedOptions are options for the Vertex AI embedder. Set ai.EmbedRequest.Options to a value of type *EmbedOptions.
type ExecutableCode ¶ added in v0.5.1
ExecutableCode represents executable code.
func GetExecutableCode ¶ added in v0.5.1
func GetExecutableCode(msg *ai.Message) *ExecutableCode
GetExecutableCode returns the first executable code from a message. Returns nil if the message doesn't contain executable code.
func ToExecutableCode ¶ added in v0.5.1
func ToExecutableCode(part *ai.Part) *ExecutableCode
ToExecutableCode tries to convert an ai.Part to an ExecutableCode. Returns nil if the part doesn't contain executable code.
type GeminiConfig ¶ added in v0.5.0
type GeminiConfig struct { // MaxOutputTokens is the maximum number of tokens to generate. MaxOutputTokens int `json:"maxOutputTokens,omitempty"` // StopSequences is the list of sequences where the model will stop generating further tokens. StopSequences []string `json:"stopSequences,omitempty"` // Temperature is the temperature to use for the model. Temperature float64 `json:"temperature,omitempty"` // TopK is the number of top tokens to consider for the model. TopK int `json:"topK,omitempty"` // TopP is the top-p value to use for the model. TopP float64 `json:"topP,omitempty"` // Version is the version of the model to use. Version string `json:"version,omitempty"` // SafetySettings is the list of safety settings to use for the model. SafetySettings []*SafetySetting `json:"safetySettings,omitempty"` // CodeExecution is whether to allow executing of code generated by the model. CodeExecution bool `json:"codeExecution,omitempty"` // Response modalities for returned model messages ResponseModalities []Modality `json:"responseModalities,omitempty"` // Thinking configuration controls the model's internal reasoning process ThinkingConfig *ThinkingConfig `json:"thinkingConfig,omitempty"` }
GeminiConfig mirrors GenerateContentConfig without direct genai dependency
type GoogleAI ¶
type GoogleAI struct { APIKey string // API key to access the service. If empty, the values of the environment variables GEMINI_API_KEY or GOOGLE_API_KEY will be consulted, in that order. // contains filtered or unexported fields }
GoogleAI is a Genkit plugin for interacting with the Google AI service.
func (*GoogleAI) DefineEmbedder ¶
DefineEmbedder defines an embedder with a given name.
func (*GoogleAI) DefineModel ¶
func (ga *GoogleAI) DefineModel(g *genkit.Genkit, name string, info *ai.ModelInfo) (ai.Model, error)
DefineModel defines an unknown model with the given name. The second argument describes the capability of the model. Use [IsDefinedModel] to determine if a model is already defined. After [Init] is called, only the known models are defined.
func (*GoogleAI) Init ¶
Init initializes the Google AI plugin and all known models and embedders. After calling Init, you may call [DefineModel] and [DefineEmbedder] to create and register any additional generative models and embedders
func (*GoogleAI) IsDefinedEmbedder ¶
IsDefinedEmbedder reports whether the named [Embedder] is defined by this plugin.
type HarmBlockMethod ¶ added in v0.5.0
type HarmBlockMethod string
Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score.
const ( // The harm block method is unspecified. HarmBlockMethodUnspecified HarmBlockMethod = "HARM_BLOCK_METHOD_UNSPECIFIED" // The harm block method uses both probability and severity scores. HarmBlockMethodSeverity HarmBlockMethod = "SEVERITY" // The harm block method uses the probability score. HarmBlockMethodProbability HarmBlockMethod = "PROBABILITY" )
type HarmBlockThreshold ¶ added in v0.5.0
type HarmBlockThreshold string
The harm block threshold.
const ( // Unspecified harm block threshold. HarmBlockThresholdUnspecified HarmBlockThreshold = "HARM_BLOCK_THRESHOLD_UNSPECIFIED" // Block low threshold and above (i.e. block more). HarmBlockThresholdBlockLowAndAbove HarmBlockThreshold = "BLOCK_LOW_AND_ABOVE" // Block medium threshold and above. HarmBlockThresholdBlockMediumAndAbove HarmBlockThreshold = "BLOCK_MEDIUM_AND_ABOVE" // Block only high threshold (i.e. block less). HarmBlockThresholdBlockOnlyHigh HarmBlockThreshold = "BLOCK_ONLY_HIGH" // Block none. HarmBlockThresholdBlockNone HarmBlockThreshold = "BLOCK_NONE" // Turn off the safety filter. HarmBlockThresholdOff HarmBlockThreshold = "OFF" )
type HarmCategory ¶ added in v0.5.0
type HarmCategory string
const ( // The harm category is unspecified. HarmCategoryUnspecified HarmCategory = "HARM_CATEGORY_UNSPECIFIED" // The harm category is hate speech. HarmCategoryHateSpeech HarmCategory = "HARM_CATEGORY_HATE_SPEECH" // The harm category is dangerous content. HarmCategoryDangerousContent HarmCategory = "HARM_CATEGORY_DANGEROUS_CONTENT" // The harm category is harassment. HarmCategoryHarassment HarmCategory = "HARM_CATEGORY_HARASSMENT" // The harm category is sexually explicit content. HarmCategorySexuallyExplicit HarmCategory = "HARM_CATEGORY_SEXUALLY_EXPLICIT" // The harm category is civic integrity. HarmCategoryCivicIntegrity HarmCategory = "HARM_CATEGORY_CIVIC_INTEGRITY" )
type SafetySetting ¶ added in v0.5.0
type SafetySetting struct { // Determines if the harm block method uses probability or probability // and severity scores. Method HarmBlockMethod `json:"method,omitempty"` // Required. Harm category. Category HarmCategory `json:"category,omitempty"` // Required. The harm block threshold. Threshold HarmBlockThreshold `json:"threshold,omitempty"` }
Safety settings.
type ThinkingConfig ¶ added in v0.5.4
type ThinkingConfig struct { // Indicates whether the response should include thoughts (if available and supported) IncludeThoughts bool `json:"includeThoughts,omitempty"` // Thinking budget in tokens. If set to zero, thinking gets disabled ThinkingBudget int32 `json:"thinkingBudget,omitempty"` }
Thinking configuration to control reasoning
type VertexAI ¶
type VertexAI struct { ProjectID string // Google Cloud project to use for Vertex AI. If empty, the value of the environment variable GOOGLE_CLOUD_PROJECT will be consulted. Location string // Location of the Vertex AI service. If empty, GOOGLE_CLOUD_LOCATION and GOOGLE_CLOUD_REGION environment variables will be consulted, in that order. // contains filtered or unexported fields }
VertexAI is a Genkit plugin for interacting with the Google Vertex AI service.
func (*VertexAI) DefineEmbedder ¶
DefineEmbedder defines an embedder with a given name.
func (*VertexAI) DefineModel ¶
DefineModel defines an unknown model with the given name. The second argument describes the capability of the model. Use [IsDefinedModel] to determine if a model is already defined. After [Init] is called, only the known models are defined.
func (*VertexAI) Init ¶
Init initializes the VertexAI plugin and all known models and embedders. After calling Init, you may call [DefineModel] and [DefineEmbedder] to create and register any additional generative models and embedders
func (*VertexAI) IsDefinedEmbedder ¶
IsDefinedEmbedder reports whether the named [Embedder] is defined by this plugin.