domain

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice struct {
	Index   int
	Message Message
}

type Message

type Message struct {
	SourceType SourceType `yaml:"source_type"` // system, user or assistant
	Content    string     `yaml:"content"`     // the message content
}

func (Message) ToYaml

func (m Message) ToYaml() string

type Provider

type Provider interface {
	ListModels() ([]string, error)

	// BasicAsk asks a question and returns the answer. The most primitive use case.
	BasicAsk(question Question) (Response, error)
	BasicAskStream(question Question) <-chan RespChunk
}

type Question

type Question struct {
	Messages []Message
}

type RespChunk

type RespChunk struct {
	Resp Response
	Err  error
}

type Response

type Response interface {
	GetChoices() []Choice
	GetUsage() Usage
}

type SourceType

type SourceType string
const (
	System    SourceType = "system"
	User      SourceType = "user"
	Assistant SourceType = "assistant"
)

Using openai naming here, we can change it later

type Usage

type Usage 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