actions

package
v0.0.0-...-ba09527 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessError

func ProcessError(err error, modelId string)

Types

type ClaudeRequest

type ClaudeRequest struct {
	Prompt            string   `json:"prompt"`
	MaxTokensToSample int      `json:"max_tokens_to_sample"`
	Temperature       float64  `json:"temperature,omitempty"`
	StopSequences     []string `json:"stop_sequences,omitempty"`
}

type ClaudeResponse

type ClaudeResponse struct {
	Completion string `json:"completion"`
}

type Completion

type Completion struct {
	Data Data `json:"data"`
}

type Data

type Data struct {
	Text string `json:"text"`
}

type ImageGenerationConfig

type ImageGenerationConfig struct {
	NumberOfImages int     `json:"numberOfImages"`
	Quality        string  `json:"quality"`
	CfgScale       float64 `json:"cfgScale"`
	Height         int     `json:"height"`
	Width          int     `json:"width"`
	Seed           int64   `json:"seed"`
}

type InvokeModelWithResponseStreamWrapper

type InvokeModelWithResponseStreamWrapper struct {
	BedrockRuntimeClient *bedrockruntime.Client
}

InvokeModelWithResponseStreamWrapper encapsulates Amazon Bedrock actions used in the examples. It contains a Bedrock Runtime client that is used to invoke foundation models.

func (InvokeModelWithResponseStreamWrapper) InvokeModelWithResponseStream

func (wrapper InvokeModelWithResponseStreamWrapper) InvokeModelWithResponseStream(prompt string) (string, error)

type InvokeModelWrapper

type InvokeModelWrapper struct {
	BedrockRuntimeClient *bedrockruntime.Client
}

InvokeModelWrapper encapsulates Amazon Bedrock actions used in the examples. It contains a Bedrock Runtime client that is used to invoke foundation models.

func (InvokeModelWrapper) InvokeClaude

func (wrapper InvokeModelWrapper) InvokeClaude(prompt string) (string, error)

Invokes Anthropic Claude on Amazon Bedrock to run an inference using the input provided in the request body.

func (InvokeModelWrapper) InvokeJurassic2

func (wrapper InvokeModelWrapper) InvokeJurassic2(prompt string) (string, error)

Invokes AI21 Labs Jurassic-2 on Amazon Bedrock to run an inference using the input provided in the request body.

func (InvokeModelWrapper) InvokeLlama2

func (wrapper InvokeModelWrapper) InvokeLlama2(prompt string) (string, error)

Invokes Meta Llama 2 Chat on Amazon Bedrock to run an inference using the input provided in the request body.

func (InvokeModelWrapper) InvokeTitanImage

func (wrapper InvokeModelWrapper) InvokeTitanImage(prompt string, seed int64) (string, error)

Invokes the Titan Image model to create an image using the input provided in the request body.

func (InvokeModelWrapper) InvokeTitanText

func (wrapper InvokeModelWrapper) InvokeTitanText(prompt string) (string, error)

type Jurassic2Request

type Jurassic2Request struct {
	Prompt      string  `json:"prompt"`
	MaxTokens   int     `json:"maxTokens,omitempty"`
	Temperature float64 `json:"temperature,omitempty"`
}

type Jurassic2Response

type Jurassic2Response struct {
	Completions []Completion `json:"completions"`
}

type Llama2Request

type Llama2Request struct {
	Prompt       string  `json:"prompt"`
	MaxGenLength int     `json:"max_gen_len,omitempty"`
	Temperature  float64 `json:"temperature,omitempty"`
}

type Llama2Response

type Llama2Response struct {
	Generation string `json:"generation"`
}

type Request

type Request struct {
	Prompt            string  `json:"prompt"`
	MaxTokensToSample int     `json:"max_tokens_to_sample"`
	Temperature       float64 `json:"temperature,omitempty"`
}

type Response

type Response struct {
	Completion string `json:"completion"`
}

type Result

type Result struct {
	TokenCount       int    `json:"tokenCount"`
	OutputText       string `json:"outputText"`
	CompletionReason string `json:"completionReason"`
}

type StreamingOutputHandler

type StreamingOutputHandler func(ctx context.Context, part []byte) error

type TextGenerationConfig

type TextGenerationConfig struct {
	Temperature   float64  `json:"temperature"`
	TopP          float64  `json:"topP"`
	MaxTokenCount int      `json:"maxTokenCount"`
	StopSequences []string `json:"stopSequences,omitempty"`
}

type TextToImageParams

type TextToImageParams struct {
	Text string `json:"text"`
}

type TitanImageRequest

type TitanImageRequest struct {
	TaskType              string                `json:"taskType"`
	TextToImageParams     TextToImageParams     `json:"textToImageParams"`
	ImageGenerationConfig ImageGenerationConfig `json:"imageGenerationConfig"`
}

type TitanImageResponse

type TitanImageResponse struct {
	Images []string `json:"images"`
}

type TitanTextRequest

type TitanTextRequest struct {
	InputText            string               `json:"inputText"`
	TextGenerationConfig TextGenerationConfig `json:"textGenerationConfig"`
}

Each model provider has their own individual request and response formats. For the format, ranges, and default values for Amazon Titan Text, refer to: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-text.html

type TitanTextResponse

type TitanTextResponse struct {
	InputTextTokenCount int      `json:"inputTextTokenCount"`
	Results             []Result `json:"results"`
}

Jump to

Keyboard shortcuts

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