Documentation
ΒΆ
Overview ΒΆ
Package bedrock provides a comprehensive AWS Bedrock plugin for Genkit Go. This plugin supports text generation, image generation, and embedding capabilities using AWS Bedrock foundation models via the Converse API.
This implementation follows the same patterns as the existing Genkit plugins: - ollama: https://github.com/firebase/genkit/blob/main/go/plugins/ollama/ollama.go - gemini: https://github.com/firebase/genkit/blob/main/go/plugins/googlegenai/gemini.go
Index ΒΆ
- func CachePointType(part *ai.Part) (types.CachePointType, bool)
- func DefineCommonEmbedders(b *Bedrock, g *genkit.Genkit) map[string]ai.Embedder
- func DefineCommonModels(b *Bedrock, g *genkit.Genkit) map[string]ai.Model
- func IsDefinedModel(g *genkit.Genkit, name string) bool
- func Model(g *genkit.Genkit, name string) ai.Model
- func NewArraySchema(itemSchema map[string]interface{}, description string) map[string]interface{}
- func NewCachePointPart() *ai.Part
- func NewNumberSchema(description string, minimum, maximum *float64) map[string]interface{}
- func NewObjectSchema(properties map[string]interface{}, required []string) map[string]interface{}
- func NewStringSchema(description string, enum []string) map[string]interface{}
- type Bedrock
- type BedrockClient
- type FinishReason
- type ModelDefinition
- type Role
- type ToolChoice
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func CachePointType ΒΆ added in v1.8.0
func CachePointType(part *ai.Part) (types.CachePointType, bool)
CachePointType retrieves the CachePointType value from the Custom field of the given ai.Part. It returns the CachePointType and a boolean indicating whether the value was found and successfully asserted.
func DefineCommonEmbedders ΒΆ
DefineCommonEmbedders is a helper to define commonly used embedders
func DefineCommonModels ΒΆ
DefineCommonModels is a helper to define commonly used models
func IsDefinedModel ΒΆ
IsDefinedModel reports whether a model is defined.
func NewArraySchema ΒΆ
NewArraySchema creates a JSON Schema for an array with the specified item type
func NewCachePointPart ΒΆ added in v1.8.0
NewCachePointPart creates and returns a new ai.Part instance representing a cache point part with the default cache point type. A cache point should be inserted after a big static prompt that is reused across multiple requests to optimize token usage.
func NewNumberSchema ΒΆ
NewNumberSchema creates a JSON Schema for a number with optional constraints
func NewObjectSchema ΒΆ
NewObjectSchema creates a JSON Schema for an object with the specified properties
func NewStringSchema ΒΆ
NewStringSchema creates a JSON Schema for a string with optional constraints
Types ΒΆ
type Bedrock ΒΆ
type Bedrock struct {
Region string // AWS region (optional, uses AWS_REGION or us-east-1)
MaxRetries int // Maximum number of retries (default: 3)
RequestTimeout time.Duration // Request timeout (default: 30s)
AWSConfig *aws.Config // Custom AWS config (optional)
// contains filtered or unexported fields
}
Bedrock provides configuration options for the AWS Bedrock plugin.
func (*Bedrock) DefineEmbedder ΒΆ
DefineEmbedder defines an embedder in the registry.
func (*Bedrock) DefineModel ΒΆ
DefineModel defines a model in the registry. This follows the same pattern as the Anthropic plugin's DefineModel method.
type BedrockClient ΒΆ
type BedrockClient = *bedrockruntime.Client
Type aliases for better readability
type FinishReason ΒΆ
type FinishReason = string
Type aliases for better readability
const ( FinishReasonStop FinishReason = "stop" FinishReasonLength FinishReason = "length" FinishReasonBlocked FinishReason = "blocked" FinishReasonOther FinishReason = "other" FinishReasonUnknown FinishReason = "unknown" )
Finish reason constants
type ModelDefinition ΒΆ
type ModelDefinition struct {
Name string // Model ID as used in AWS Bedrock
Type string // Type: "chat", "text", "image", "embedding"
}
ModelDefinition represents a model with its name and type.
type ToolChoice ΒΆ
type ToolChoice = string
Type aliases for better readability
const ( ToolChoiceAuto ToolChoice = "auto" ToolChoiceRequired ToolChoice = "required" ToolChoiceNone ToolChoice = "none" )
Tool choice constants
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
examples
|
|
|
advanced_schemas
command
Package main demonstrates advanced schema usage with AWS Bedrock tool calling
|
Package main demonstrates advanced schema usage with AWS Bedrock tool calling |
|
basic
command
Package main demonstrates basic usage of the AWS Bedrock plugin
|
Package main demonstrates basic usage of the AWS Bedrock plugin |
|
embeddings
command
Package main demonstrates embedding generation with AWS Bedrock
|
Package main demonstrates embedding generation with AWS Bedrock |
|
image_generation
command
Package main demonstrates image generation with AWS Bedrock
|
Package main demonstrates image generation with AWS Bedrock |
|
multimodal
command
Package main demonstrates multimodal conversation with AWS Bedrock
|
Package main demonstrates multimodal conversation with AWS Bedrock |
|
prompt_caching
command
|
|
|
streaming
command
Package main demonstrates streaming text generation with AWS Bedrock
|
Package main demonstrates streaming text generation with AWS Bedrock |
|
tool_calling
command
Package main demonstrates tool calling capabilities with AWS Bedrock
|
Package main demonstrates tool calling capabilities with AWS Bedrock |