bedrock

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/*
		ModelCohereEn is the model id for the cohere english embeddings.

		  ModelDimensions := 1024
		  MaxTokens := 512
		  Languages := []string{"English"}
	*/
	ModelCohereEn = "cohere.embed-english-v3"

	/*
		ModelCohereMulti is the model id for the cohere multilingual embeddings.

		  ModelDimensions := 1024
		  MaxTokens:= 512
		  Languages := [108]string
	*/
	ModelCohereMulti = "cohere.embed-multilingual-v3"
)
View Source
const (
	// CohereInputTypeText is the input type for text embeddings.
	CohereInputTypeText = "search_document"
	// CohereInputTypeQuery is the input type for query embeddings.
	CohereInputTypeQuery = "search_query"
)
View Source
const (
	/*
		ModelTitanEmbedG1 is the model id for the amazon text embeddings.

		  MaxTokens := 8000
		  ModelDimensions := 1536
		  Languages := []string{"English", "Arabic", "Chinese (Simplified)", "French", "German", "Hindi", "Japanese", "Spanish", "Czech", "Filipino", "Hebrew", "Italian", "Korean", "Portuguese", "Russian", "Swedish", "Turkish", "Chinese (Traditional)", "Dutch", "Kannada", "Malayalam", "Marathi", "Polish", "Tamil", "Telugu", ...}
	*/
	ModelTitanEmbedG1 = "amazon.titan-embed-text-v1"
)

Variables

This section is empty.

Functions

func FetchAmazonTextEmbeddings

func FetchAmazonTextEmbeddings(ctx context.Context,
	client *bedrockruntime.Client,
	modelID string,
	texts []string,
) ([][]float32, error)

func FetchCohereTextEmbeddings

func FetchCohereTextEmbeddings(
	ctx context.Context,
	client *bedrockruntime.Client,
	modelID string,
	inputs []string,
	inputType string,
) ([][]float32, error)

Types

type Bedrock

type Bedrock struct {
	ModelID string

	StripNewLines bool
	BatchSize     int
	// contains filtered or unexported fields
}

Bedrock is the embedder used generate text embeddings through Amazon Bedrock.

func NewBedrock

func NewBedrock(opts ...Option) (*Bedrock, error)

NewBedrock returns a new embeddings.Embedder that uses Amazon Bedrock to generate embeddings.

func (*Bedrock) EmbedDocuments

func (b *Bedrock) EmbedDocuments(ctx context.Context, texts []string) ([][]float32, error)

EmbedDocuments implements embeddings.Embedder and generates embeddings for the supplied texts.

func (*Bedrock) EmbedQuery

func (b *Bedrock) EmbedQuery(ctx context.Context, text string) ([]float32, error)

EmbedQuery implements embeddings.Embedder and generates an embedding for the supplied text.

type Option

type Option func(p *Bedrock)

Option is a function type that can be used to modify the client.

func WithBatchSize

func WithBatchSize(batchSize int) Option

WithBatchSize is an option for specifying the batch size. Only applicable to Cohere provider.

func WithClient

func WithClient(client *bedrockruntime.Client) Option

WithClient is an option for providing the Bedrock client.

func WithModel

func WithModel(model string) Option

WithModel is an option for providing the model name to use.

func WithStripNewLines

func WithStripNewLines(stripNewLines bool) Option

WithStripNewLines is an option for specifying the should it strip new lines.

Jump to

Keyboard shortcuts

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