Documentation
¶
Index ¶
- Variables
- func EmbedderRef(name string, config *genai.EmbedContentConfig) ai.EmbedderRef
- func GetEmbedderOptions(name, provider string) ai.EmbedderOptions
- func GetModelOptions(name, provider string) ai.ModelOptions
- func GoogleAIEmbedder(g *genkit.Genkit, name string) ai.Embedderdeprecated
- func GoogleAIModel(g *genkit.Genkit, name string) ai.Modeldeprecated
- func GoogleAIModelRef(id string, config *genai.GenerateContentConfig) ai.ModelRefdeprecated
- func HasCodeExecution(msg *ai.Message) bool
- func ImageModelRef(name string, config *genai.GenerateImagesConfig) ai.ModelRef
- func ModelRef(name string, config *genai.GenerateContentConfig) ai.ModelRef
- func VertexAIEmbedder(g *genkit.Genkit, name string) ai.Embedderdeprecated
- func VertexAIModel(g *genkit.Genkit, name string) ai.Modeldeprecated
- func VertexAIModelRef(id string, config *genai.GenerateContentConfig) ai.ModelRefdeprecated
- func VideoModelRef(name string, config *genai.GenerateVideosConfig) ai.ModelRef
- type CodeExecutionResult
- type ExecutableCode
- type GoogleAI
- func (ga *GoogleAI) DefineEmbedder(g *genkit.Genkit, name string, embedOpts *ai.EmbedderOptions) (ai.Embedder, error)
- func (ga *GoogleAI) DefineModel(g *genkit.Genkit, name string, opts *ai.ModelOptions) (ai.Model, error)
- func (ga *GoogleAI) Init(ctx context.Context) []api.Action
- func (ga *GoogleAI) IsDefinedEmbedder(g *genkit.Genkit, name string) bool
- func (ga *GoogleAI) ListActions(ctx context.Context) []api.ActionDesc
- func (ga *GoogleAI) Name() string
- func (ga *GoogleAI) ResolveAction(atype api.ActionType, name string) api.Action
- type ModelType
- type VertexAI
- func (v *VertexAI) DefineEmbedder(g *genkit.Genkit, name string, embedOpts *ai.EmbedderOptions) (ai.Embedder, error)
- func (v *VertexAI) DefineModel(g *genkit.Genkit, name string, opts *ai.ModelOptions) (ai.Model, error)
- func (v *VertexAI) Init(ctx context.Context) []api.Action
- func (v *VertexAI) IsDefinedEmbedder(g *genkit.Genkit, name string) bool
- func (v *VertexAI) ListActions(ctx context.Context) []api.ActionDesc
- func (v *VertexAI) Name() string
- func (v *VertexAI) ResolveAction(atype api.ActionType, name string) api.Action
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, } // Media describes model capabilities for image generation models (Imagen). Media = ai.ModelSupports{ Multiturn: false, Tools: false, SystemRole: false, Media: true, Output: []string{"media"}, } // VeoSupports describes model capabilities for video generation models (Veo). VeoSupports = ai.ModelSupports{ Media: true, Multiturn: false, Tools: false, SystemRole: false, Output: []string{"media"}, LongRunning: true, } )
Model capability definitions - these describe what different model types support.
Functions ¶
func EmbedderRef ¶ added in v1.5.0
func EmbedderRef(name string, config *genai.EmbedContentConfig) ai.EmbedderRef
EmbedderRef creates an EmbedderRef for an embedding model. The name should include provider prefix (e.g., "googleai/text-embedding-004").
func GetEmbedderOptions ¶ added in v1.5.0
func GetEmbedderOptions(name, provider string) ai.EmbedderOptions
GetEmbedderOptions returns EmbedderOptions for an embedder name with provider-prefixed label.
func GetModelOptions ¶ added in v1.5.0
func GetModelOptions(name, provider string) ai.ModelOptions
GetModelOptions returns ModelOptions for a model name with provider-prefixed label.
func GoogleAIEmbedder
deprecated
func GoogleAIModelRef
deprecated
added in
v0.5.0
func GoogleAIModelRef(id string, config *genai.GenerateContentConfig) ai.ModelRef
GoogleAIModelRef creates a ModelRef for a Google AI Gemini model.
Deprecated: Use ModelRef with full name instead.
func HasCodeExecution ¶ added in v0.5.1
HasCodeExecution checks if a message contains code execution results or executable code.
func ImageModelRef ¶ added in v1.5.0
func ImageModelRef(name string, config *genai.GenerateImagesConfig) ai.ModelRef
ImageModelRef creates a ModelRef for an image generation model. The name should include provider prefix (e.g., "googleai/imagen-3.0-generate-001").
func ModelRef ¶ added in v1.3.0
func ModelRef(name string, config *genai.GenerateContentConfig) ai.ModelRef
ModelRef creates a ModelRef for a Gemini model. The name should include provider prefix (e.g., "googleai/gemini-2.0-flash").
func VertexAIEmbedder
deprecated
func VertexAIModelRef
deprecated
added in
v0.5.0
func VertexAIModelRef(id string, config *genai.GenerateContentConfig) ai.ModelRef
VertexAIModelRef creates a ModelRef for a Vertex AI Gemini model.
Deprecated: Use ModelRef with full name instead.
func VideoModelRef ¶ added in v1.5.0
func VideoModelRef(name string, config *genai.GenerateVideosConfig) ai.ModelRef
VideoModelRef creates a ModelRef for a video generation model. The name should include provider prefix (e.g., "googleai/veo-2.0-generate-001").
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 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 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 ¶
func (ga *GoogleAI) DefineEmbedder(g *genkit.Genkit, name string, embedOpts *ai.EmbedderOptions) (ai.Embedder, error)
DefineEmbedder defines an embedder with a given name.
func (*GoogleAI) DefineModel ¶
func (ga *GoogleAI) DefineModel(g *genkit.Genkit, name string, opts *ai.ModelOptions) (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.
func (*GoogleAI) ListActions ¶ added in v0.6.0
func (ga *GoogleAI) ListActions(ctx context.Context) []api.ActionDesc
ListActions lists all the actions supported by the Google AI plugin.
func (*GoogleAI) ResolveAction ¶ added in v0.6.0
ResolveAction resolves an action with the given name.
type ModelType ¶ added in v1.5.0
type ModelType int
ModelType categorizes models by their generation modality.
func ClassifyModel ¶ added in v1.5.0
ClassifyModel determines the model type from its name. This is the single source of truth for model type classification.
func (ModelType) ActionType ¶ added in v1.5.0
func (mt ModelType) ActionType() api.ActionType
ActionType returns the appropriate API action type for this model type.
func (ModelType) DefaultConfig ¶ added in v1.5.0
DefaultConfig returns the default config struct for this model type.
func (ModelType) DefaultSupports ¶ added in v1.5.0
func (mt ModelType) DefaultSupports() *ai.ModelSupports
DefaultSupports returns the default ModelSupports for this model type.
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 ¶
func (v *VertexAI) DefineEmbedder(g *genkit.Genkit, name string, embedOpts *ai.EmbedderOptions) (ai.Embedder, error)
DefineEmbedder defines an embedder with a given name.
func (*VertexAI) DefineModel ¶
func (v *VertexAI) DefineModel(g *genkit.Genkit, name string, opts *ai.ModelOptions) (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 (*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.
func (*VertexAI) ListActions ¶ added in v0.6.0
func (v *VertexAI) ListActions(ctx context.Context) []api.ActionDesc
ListActions lists all the actions supported by the Vertex AI plugin.
func (*VertexAI) ResolveAction ¶ added in v0.6.0
ResolveAction resolves an action with the given name.