model

package
v0.0.0-...-06ac272 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmazonBedrockInvocationMetrics

type AmazonBedrockInvocationMetrics struct {
	InputTokenCount   int `json:"inputTokenCount"`
	OutputTokenCount  int `json:"outputTokenCount"`
	InvocationLatency int `json:"invocationLatency"`
	FirstByteLatency  int `json:"firstByteLatency"`
}

type CarbonFootprintEstimator

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

func NewCarbonFootprintEstimator

func NewCarbonFootprintEstimator(tpd, mem, carbonIntensity int) *CarbonFootprintEstimator

func (*CarbonFootprintEstimator) EstimateModelInvocationCarbonFootprint

func (m *CarbonFootprintEstimator) EstimateModelInvocationCarbonFootprint(metadata *InvocationLogMetadata) *InvocationLogMetadata

type CostDetail

type CostDetail struct {
	Name     string `json:"name"`
	Provider string `json:"provider"`
	Cost     []struct {
		Region                string  `json:"region"`
		InputCostPer1KTokens  float64 `json:"input_cost_per_1k_tokens"`
		OutputCostPer1KTokens float64 `json:"output_cost_per_1k_tokens"`
	} `json:"cost"`
}

type CostEstimator

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

func NewCostEstimator

func NewCostEstimator(modelsPriceDetails []byte) (*CostEstimator, error)

func (*CostEstimator) EstimateModelInvocationCost

func (m *CostEstimator) EstimateModelInvocationCost(metadata *InvocationLogMetadata) *InvocationLogMetadata

type IdentityTag

type IdentityTag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type IdentityTagsBuilder

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

func NewIdentityTagsBuilder

func NewIdentityTagsBuilder(iamClient *iam.IAM) *IdentityTagsBuilder

func (*IdentityTagsBuilder) GetIdentityTags

func (i *IdentityTagsBuilder) GetIdentityTags(identity string) (tags []*iam.Tag, err error)

type InvocationLog

type InvocationLog struct {
	SchemaType    string    `json:"schemaType"`
	SchemaVersion string    `json:"schemaVersion"`
	Timestamp     time.Time `json:"timestamp"`
	AccountID     string    `json:"accountId"`
	Identity      struct {
		Arn string `json:"arn"`
	} `json:"identity"`
	Region    string `json:"region"`
	RequestID string `json:"requestId"`
	Operation string `json:"operation"`
	ModelID   string `json:"modelId"`
	Input     struct {
		InputContentType string `json:"inputContentType"`
		InputTokenCount  int    `json:"inputTokenCount"`
	} `json:"input"`
	Output struct {
		OutputContentType string `json:"outputContentType"`
		OutputTokenCount  int    `json:"outputTokenCount"`
		OutputBodyJSON    any    `json:"outputBodyJson"`
	} `json:"output"`
}

type InvocationLogMetadata

type InvocationLogMetadata struct {
	Timestamp time.Time `json:"timestamp"`
	AccountID string    `json:"accountId"`
	Identity  struct {
		Arn string `json:"arn"`
	} `json:"identity"`
	IdentityTags         []IdentityTag `json:"identityTags"`
	Region               string        `json:"region"`
	RequestID            string        `json:"requestId"`
	Operation            string        `json:"operation"`
	ModelID              string        `json:"modelId"`
	ModelName            string        `json:"modelName"`
	ModelProvider        string        `json:"modelProvider"`
	InputContentType     string        `json:"inputContentType"`
	OutputContentType    string        `json:"outputContentType"`
	InputTokenCount      int           `json:"inputTokenCount"`
	OutputTokenCount     int           `json:"outputTokenCount"`
	InputTokenCostUSD    float64       `json:"inputTokenCostUSD"`
	OutputTokenCostUSD   float64       `json:"outputTokenCostUSD"`
	InvocationLatency    int           `json:"invocationLatency,omitempty"`
	FirstByteLatency     int           `json:"firstByteLatency,omitempty"`
	EnergyConsumptionkWh float64       `json:"energyConsumptionkWh,omitempty"`
	CarbonEmissiongCO2e  float64       `json:"carbonEmissiongCO2e,omitempty"`
}

type InvocationLogOutputBodyJSON

type InvocationLogOutputBodyJSON struct {
	OutputText                     string                         `json:"outputText"`
	Index                          int                            `json:"index"`
	TotalOutputTextTokenCount      any                            `json:"totalOutputTextTokenCount"`
	CompletionReason               any                            `json:"completionReason"`
	InputTextTokenCount            int                            `json:"inputTextTokenCount"`
	AmazonBedrockInvocationMetrics AmazonBedrockInvocationMetrics `json:"amazon-bedrock-invocationMetrics,omitempty"`
}

type MetadataGenerator

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

func NewMetadataGenerator

func NewMetadataGenerator(modelCost *CostEstimator, carbonFootprint *CarbonFootprintEstimator, identity *IdentityTagsBuilder) *MetadataGenerator

func (*MetadataGenerator) GenerateModelInvocationLogMetadata

func (m *MetadataGenerator) GenerateModelInvocationLogMetadata(modelInvocationLog *InvocationLog) (modelInvocationLogMetadata *InvocationLogMetadata, err error)

Jump to

Keyboard shortcuts

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