model

package
v0.1.7-alpha Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateContentGemini

func GenerateContentGemini(ctx context.Context, modelName string, cfg Config, w io.Writer, parts []genai.Part) error

GenerateContentGemini calls Gemini's generate content method

func UseClaudeModel

func UseClaudeModel(ctx context.Context, modelName string, cfg Config, args []string) error

TODO - Add documentation for function

func UseGeminiModel

func UseGeminiModel(ctx context.Context, modelName string, cfg Config, args []string) error

UseGeminiModel calls Gemini's generate content method

func UsePaLMModel

func UsePaLMModel(ctx context.Context, modelName string, cfg Config, args []string) error

UsePaLMModel calls PaLM's generate content method

Types

type AnthropicContent

type AnthropicContent struct {
	Text string `json:"text,omitempty"`
	Type string `json:"type,omitempty"`
}

AnthropicContent is the content of a message to the Claude model.

type AnthropicMessage

type AnthropicMessage struct {
	Content []AnthropicContent `json:"content,omitempty"`
	Role    string             `json:"role,omitempty"`
}

AnthropicMessage is a message to the Claude model.

type AnthropicRequest

type AnthropicRequest struct {
	AnthropicVersion string             `json:"anthropic_version,omitempty"`
	MaxTokens        int                `json:"max_tokens,omitempty"`
	Messages         []AnthropicMessage `json:"messages,omitempty"`
	Stream           bool               `json:"stream,omitempty"`
	TopP             float32            `json:"top_p,omitempty"`
	TopK             int                `json:"top_k,omitempty"`
	Temperature      float32            `json:"temperature,omitempty"`
}

AnthropicRequest is the request to the Claude model.

type AnthropicResponse

type AnthropicResponse struct {
	ID           string             `json:"id,omitempty"`
	Type         string             `json:"type,omitempty"`
	Role         string             `json:"role,omitempty"`
	Content      []AnthropicContent `json:"content,omitempty"`
	Model        string             `json:"model,omitempty"`
	StopReason   string             `json:"stop_reason,omitempty"`
	StopSequence string             `json:"stop_sequence,omitempty"`
	Usage        AnthropicUsage     `json:"usage,omitempty"`
}

AnthropicResponse is the response from the Claude model.

type AnthropicUsage

type AnthropicUsage struct {
	InputTokens  int `json:"input_tokens,omitempty"`
	OutputTokens int `json:"output_tokens,omitempty"`
}

TODO - Add documentation for type

type CitationMetadata

type CitationMetadata struct {
	Citations []interface{} `json:"citations"`
}

type Config

type Config struct {
	ProjectID  string
	RegionID   string
	ConfigFile string
	LogType    string
	OutputType string
}

func (Config) ReadModelConfigFile

func (cfg Config) ReadModelConfigFile() (map[string]interface{}, error)

readModelConfigFile reads the model configuration file (JSON text file)

type ConfigBuilder

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

func (*ConfigBuilder) Build

func (b *ConfigBuilder) Build() (Config, error)

func (*ConfigBuilder) ConfigFile

func (b *ConfigBuilder) ConfigFile(configFile string) *ConfigBuilder

func (*ConfigBuilder) Describe

func (b *ConfigBuilder) Describe() string

func (*ConfigBuilder) LogType

func (b *ConfigBuilder) LogType(logType string) *ConfigBuilder

TODO - Need to document allowed values and validate input

func (*ConfigBuilder) OutputType

func (b *ConfigBuilder) OutputType(outputType string) *ConfigBuilder

TODO - Need to document allowed values and validate input

func (*ConfigBuilder) ProjectID

func (b *ConfigBuilder) ProjectID(p string) *ConfigBuilder

func (*ConfigBuilder) RegionID

func (b *ConfigBuilder) RegionID(r string) *ConfigBuilder

TODO - Need to document allowed values and validate input

type Metadata

type Metadata struct {
	TokenMetadata TokenMetadata `json:"tokenMetadata"`
}

type Model

type Model struct {
	Family string `json:"family"`
	Mode   string `json:"mode"`
	Name   string `json:"name"`
	// contains filtered or unexported fields
}

A Model sends prompts to a specific GenAI model using an Endpoint location, where the model is enabled and billed

func Get

func Get(name string) (Model, error)

func List

func List() ([]Model, error)

func (Model) Use

func (m Model) Use(ctx context.Context, cfg Config, args []string) error

TODO - Ideally would like to avoid this level of indirection, but suing it for the

time being to get course grained refactoring working

type PaLMResponse

type PaLMResponse struct {
	Predictions []Prediction `json:"predictions"`
	Metadata    Metadata     `json:"metadata"`
}

PaLMResponse is the response from the PaLM model.

type Prediction

type Prediction struct {
	CitationMetadata CitationMetadata `json:"citationMetadata,omitempty"`
	Content          string           `json:"content,omitempty"`
	SafetyAttributes SafetyAttributes `json:"safetyAttributes,omitempty"`
}

type SafetyAttributes

type SafetyAttributes struct {
	Blocked       bool           `json:"blocked,omitempty"`
	Categories    []string       `json:"categories,omitempty"`
	SafetyRatings []SafetyRating `json:"safetyRatings,omitempty"`
}

type SafetyRating

type SafetyRating struct {
	Category         string  `json:"category,omitempty"`
	ProbabilityScore float32 `json:"probabilityScore,omitempty"`
	Severity         string  `json:"severity,omitempty"`
	SeverityScore    float32 `json:"severityScore,omitempty"`
}

type TokenMetadata

type TokenMetadata struct {
	InputTokenCount  TokenMetadataDetails `json:"inputTokenCount,omitempty"`
	OutputTokenCount TokenMetadataDetails `json:"outputTokenCount,omitempty"`
}

type TokenMetadataDetails

type TokenMetadataDetails struct {
	TotalBillableCharacters int `json:"totalBillableCharacters,omitempty"`
	TotalTokens             int `json:"totalTokens,omitempty"`
}

Jump to

Keyboard shortcuts

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