googlegenai

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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,
	}
)
View Source
var Media = ai.ModelSupports{
	Media:      true,
	Multiturn:  false,
	Tools:      false,
	ToolChoice: false,
	SystemRole: false,
}

Media describes model capabilities for Gemini models with media and text input and image only output

Functions

func GoogleAIEmbedder

func GoogleAIEmbedder(g *genkit.Genkit, name string) ai.Embedder

GoogleAIEmbedder returns the ai.Embedder with the given name. It returns nil if the embedder was not defined.

func GoogleAIModel

func GoogleAIModel(g *genkit.Genkit, name string) ai.Model

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 *genai.GenerateContentConfig) 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

func HasCodeExecution(msg *ai.Message) bool

HasCodeExecution checks if a message contains code execution results or executable code.

func NewCodeExecutionResultPart added in v0.5.1

func NewCodeExecutionResultPart(outcome string, output string) *ai.Part

NewCodeExecutionResultPart returns a Part containing the result of code execution.

func NewExecutableCodePart added in v0.5.1

func NewExecutableCodePart(language string, code string) *ai.Part

NewExecutableCodePart returns a Part containing executable code.

func VertexAIEmbedder

func VertexAIEmbedder(g *genkit.Genkit, name string) ai.Embedder

VertexAIEmbedder returns the ai.Embedder with the given name. It returns nil if the embedder was not defined.

func VertexAIModel

func VertexAIModel(g *genkit.Genkit, name string) ai.Model

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 *genai.GenerateContentConfig) 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

type CodeExecutionResult struct {
	Outcome string `json:"outcome"`
	Output  string `json:"output"`
}

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

type ExecutableCode struct {
	Language string `json:"language"`
	Code     string `json:"code"`
}

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) (ai.Embedder, error)

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

func (ga *GoogleAI) Init(ctx context.Context, g *genkit.Genkit) (err error)

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

func (ga *GoogleAI) IsDefinedEmbedder(g *genkit.Genkit, name string) bool

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) []core.ActionDesc

func (*GoogleAI) Name

func (ga *GoogleAI) Name() string

Name returns the name of the plugin.

func (*GoogleAI) ResolveAction added in v0.6.0

func (ga *GoogleAI) ResolveAction(g *genkit.Genkit, atype core.ActionType, name string) error

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) (ai.Embedder, error)

DefineEmbedder defines an embedder with a given name.

func (*VertexAI) DefineModel

func (v *VertexAI) 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 (*VertexAI) Init

func (v *VertexAI) Init(ctx context.Context, g *genkit.Genkit) (err error)

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

func (v *VertexAI) IsDefinedEmbedder(g *genkit.Genkit, name string) bool

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) []core.ActionDesc

func (*VertexAI) Name

func (v *VertexAI) Name() string

Name returns the name of the plugin.

func (*VertexAI) ResolveAction added in v0.6.0

func (v *VertexAI) ResolveAction(g *genkit.Genkit, atype core.ActionType, name string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL