common

package
v0.0.0-...-66bbac4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LLM

type LLM interface {
	Generate(...string) (LLMResult, error)
	GenerateWithContext(context.Context, ...string) (LLMResult, error)
	GenerateWithOptions(context.Context, LLMOptions) (LLMResult, error)

	GenerateStream(io.Writer, ...string) (LLMResult, error)
	GenerateStreamWithContext(context.Context, io.Writer, ...string) (LLMResult, error)
	GenerateStreamWithOptions(context.Context, io.Writer, LLMOptions) (LLMResult, error)
}

type LLMCost

type LLMCost struct {
	PromptCost     float64
	CompletionCost float64
	TotalCost      float64
}

type LLMGeneration

type LLMGeneration struct {
	Text         string
	Index        int
	FinishReason string
}

type LLMModel

type LLMModel schema.Model

type LLMOptions

type LLMOptions interface {
	GetRequest() interface{}
	WithPrompt(any) LLMOptions
	WithModel(model string) LLMOptions
	WithMaxTokens(maxTokens int) LLMOptions
	WithTemperature(temperature float32) LLMOptions
	WithTopP(topP float32) LLMOptions
	WithN(n int) LLMOptions
	WithStream(stream bool) LLMOptions
	WithStop(stop []string) LLMOptions
	WithPresencePenalty(presencePenalty float32) LLMOptions
	WithFrequencyPenalty(frequencyPenalty float32) LLMOptions
	WithLogitBias(logitBias map[string]int) LLMOptions
	WithUser(user string) LLMOptions
	GetPrompt() []string
	WithTimeout(time.Duration) LLMOptions
	GetTimeout() time.Duration
}

type LLMResult

type LLMResult struct {
	Generations []LLMGeneration
	Usage       LLMUsage
	Cost        LLMCost
}

func (*LLMResult) CalculateCosts

func (c *LLMResult) CalculateCosts(m *LLMModel)

type LLMUsage

type LLMUsage struct {
	PromptTokens     int
	CompletionTokens int
	TotalTokens      int
}

Jump to

Keyboard shortcuts

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