bedrock

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: MIT Imports: 15 Imported by: 5

Documentation

Index

Constants

View Source
const (
	LLAMA3_0_8B_INSTRUCT   = Llama3("meta.llama3-8b-instruct-v1:0")
	LLAMA3_0_70B_INSTRUCT  = Llama3("meta.llama3-70b-instruct-v1:0")
	LLAMA3_1_8B_INSTRUCT   = Llama3("meta.llama3-1-8b-instruct-v1:0")
	LLAMA3_1_70B_INSTRUCT  = Llama3("meta.llama3-1-70b-instruct-v1:0")
	LLAMA3_1_405B_INSTRUCT = Llama3("meta.llama3-1-405b-instruct-v1:0")
	LLAMA3_2_1B_INSTRUCT   = Llama3("meta.llama3-2-1b-instruct-v1:0")
	LLAMA3_2_3B_INSTRUCT   = Llama3("meta.llama3-2-3b-instruct-v1:0")
	LLAMA3_2_11B_INSTRUCT  = Llama3("meta.llama3-2-11b-instruct-v1:0")
	LLAMA3_2_90B_INSTRUCT  = Llama3("meta.llama3-2-90b-instruct-v1:0")
)

See model id https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html#model-ids-arns

View Source
const (
	TITAN_TEXT_LITE_V1    = Titan("amazon.titan-text-lite-v1")
	TITAN_TEXT_EXPRESS_V1 = Titan("amazon.titan-text-express-v1")
	TITAN_TEXT_PREMIER_V1 = Titan("amazon.titan-text-premier-v1:0")
)

See https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html

View Source
const Version = "bedrock/v0.2.0"

Variables

View Source
var (
	// Set AWS Bedrock Foundational LLM
	//
	// This option is required.
	WithLLM = opts.ForType[Client, LLM]()

	// Use aws.Config to config the client
	WithConfig = opts.FMap(optsFromConfig)

	// Use region for aws.Config
	WithRegion = opts.FMap(optsFromRegion)

	// Set us-west-2 as default region
	WithDefaultRegion = WithRegion(defaultRegion)

	// Set AWS Bedrock Runtime
	WithBedrock = opts.ForType[Client, Bedrock]()
)

Functions

This section is empty.

Types

type Bedrock added in v0.0.6

type Bedrock interface {
	InvokeModel(ctx context.Context, params *bedrockruntime.InvokeModelInput, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelOutput, error)
}

AWS Bedrock Runtime API

type Client

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

AWS Bedrock client

func New

func New(opt ...Option) (*Client, error)

Create client to AWS BedRock.

By default `us-east-1` region is used, use config options to alter behavior.

func (*Client) Prompt added in v0.0.4

func (c *Client) Prompt(ctx context.Context, prompt []fmt.Stringer, opts ...chatter.Opt) (chatter.Reply, error)

Prompt the model

func (*Client) UsedInputTokens added in v0.0.6

func (c *Client) UsedInputTokens() int

func (*Client) UsedReplyTokens added in v0.0.6

func (c *Client) UsedReplyTokens() int

type FoundationModel added in v0.0.5

type FoundationModel struct {
	constructs.Construct
	// contains filtered or unexported fields
}

func NewFoundationModel added in v0.0.5

func NewFoundationModel(scope constructs.Construct, id *string, foundationModelId awsbedrock.FoundationModelIdentifier) *FoundationModel

func NewMetaLlama30B70V1 added in v0.0.5

func NewMetaLlama30B70V1(scope constructs.Construct) *FoundationModel

func NewMetaLlama30B8V1 added in v0.0.5

func NewMetaLlama30B8V1(scope constructs.Construct) *FoundationModel

func NewMetaLlama31B405V1 added in v0.0.5

func NewMetaLlama31B405V1(scope constructs.Construct) *FoundationModel

func NewMetaLlama31B70V1 added in v0.0.5

func NewMetaLlama31B70V1(scope constructs.Construct) *FoundationModel

func NewMetaLlama31B8V1 added in v0.0.5

func NewMetaLlama31B8V1(scope constructs.Construct) *FoundationModel

func NewMetaLlama32B11V1 added in v0.0.5

func NewMetaLlama32B11V1(scope constructs.Construct) *FoundationModel

func NewMetaLlama32B1V1 added in v0.0.5

func NewMetaLlama32B1V1(scope constructs.Construct) *FoundationModel

func NewMetaLlama32B3V1 added in v0.0.5

func NewMetaLlama32B3V1(scope constructs.Construct) *FoundationModel

func NewMetaLlama32B90V1 added in v0.0.5

func NewMetaLlama32B90V1(scope constructs.Construct) *FoundationModel

func NewTitanTextExpressV1 added in v0.0.5

func NewTitanTextExpressV1(scope constructs.Construct) *FoundationModel

func NewTitanTextLiteV1 added in v0.0.5

func NewTitanTextLiteV1(scope constructs.Construct) *FoundationModel

func NewTitanTextPremierV1 added in v0.0.5

func NewTitanTextPremierV1(scope constructs.Construct) *FoundationModel

func (*FoundationModel) GrantAccess added in v0.0.5

func (c *FoundationModel) GrantAccess(grantee awsiam.IGrantable)

type LLM added in v0.0.6

type LLM chatter.LLM

type Llama3 added in v0.0.4

type Llama3 string

Meta Llama3 model family

See * https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-meta.html * https://www.llama.com/docs/model-cards-and-prompt-formats/llama-guard-3 * https://www.llama.com/docs/model-cards-and-prompt-formats/meta-llama-3/

func (Llama3) Decode added in v0.0.4

func (Llama3) Decode(data []byte) (r chatter.Reply, err error)

func (Llama3) Encode added in v0.0.4

func (v Llama3) Encode(prompt []fmt.Stringer, opts ...chatter.Opt) (req []byte, err error)

func (Llama3) ModelID added in v0.0.7

func (v Llama3) ModelID() string

type Option

type Option = opts.Option[Client]

type Titan added in v0.0.6

type Titan string

Amazon Titan Text model family

See https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-text.html See https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-templates-and-examples.html

func (Titan) Decode added in v0.0.6

func (Titan) Decode(data []byte) (r chatter.Reply, err error)

func (Titan) Encode added in v0.0.6

func (Titan) Encode(prompt []fmt.Stringer, opts ...chatter.Opt) (req []byte, err error)

func (Titan) ModelID added in v0.0.7

func (v Titan) ModelID() string

Jump to

Keyboard shortcuts

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