bedrock

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRegion is default AWS region
	DefaultRegion = "us-east-1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new AWS Bedrock HTTP API client and returns it. By default it reads the default AWS evnironment variables. and constructs the AWS API client.

func (*Client) Embed

func (c *Client) Embed(ctx context.Context, embReq *Request) ([]*embeddings.Embedding, error)

Embed returns embeddings for every object in EmbeddingRequest.

type Model

type Model string

Model is embedding model.

const (
	TitanTextV1 Model = "amazon.titan-embed-text-v1"
	TitanTextV2 Model = "amazon.titan-embed-text-v2:0"
)

func (Model) String

func (m Model) String() string

String implements stringer.

type Option

type Option func(*Options)

Option is functional option.

func WithBedrockClient

func WithBedrockClient(client *bedrockruntime.Client) Option

WithBedrockClient sets Bedrock API client.

func WithModelID

func WithModelID(id string) Option

WithModelID sets the Tital embedding model ID>

func WithRegion

func WithRegion(region string) Option

WithRegion sets AWS region.

type Options

type Options struct {
	Region  string
	ModelID string
	Client  *bedrockruntime.Client
}

type Request

type Request struct {
	InputText string `json:"inputText"`
}

type Response

type Response struct {
	Embedding           []float64 `json:"embedding"`
	InputTextTokenCount int       `json:"inputTextTokenCount"`
}

func (*Response) ToEmbeddings

func (e *Response) ToEmbeddings() ([]*embeddings.Embedding, error)

Jump to

Keyboard shortcuts

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