llm

package
v0.0.0-...-96647dd Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeveloperMessage

func DeveloperMessage(content string) openai.ChatCompletionMessageParamUnion

func Send

func Send(cfg *Config, ctx context.Context, role, prompt, input string) (string, error)

Types

type Config

type Config struct {
	Workspace string

	Model   string
	BaseUrl string
	ApiKey  string

	L1Model   string
	L1BaseUrl string
	L1ApiKey  string

	L2Model   string
	L2BaseUrl string
	L2ApiKey  string

	L3Model   string
	L3BaseUrl string
	L3ApiKey  string

	Debug bool

	DryRun        bool
	DryRunContent string

	Editor string

	// Current working directory where AI script is executed
	WorkDir string

	Interactive bool

	Clipin  bool
	Clipout bool
	Stdin   bool

	Me string

	MetaPrompt bool

	Command string
	Args    []string

	Tools []openai.ChatCompletionToolParam

	DBConfig *db.DBConfig `mapstructure:"db"`

	ConfigFile string

	// ai binary path
	CommandPath string

	//
	Git *GitConfig
}

func (*Config) Clone

func (cfg *Config) Clone() *Config

type GitConfig

type GitConfig struct {
	Short bool
}

type Level

type Level int

Level represents the "intelligence" level of the model. i.e. basic, regular, advanced for example, OpenAI: gpt-4o-mini, gpt-4o, gpt-o1

const (
	L0 Level = iota
	L1
	L2
	L3
)

type Message

type Message struct {
	Role   string
	Prompt string
	Model  *Model

	Input   string
	DBCreds *db.DBConfig

	Content string
}

func Chat

func Chat(ctx context.Context, req *Message) (*Message, error)

type Model

type Model struct {
	Name    string
	BaseUrl string
	ApiKey  string

	Tools []openai.ChatCompletionToolParam

	DryRun        bool
	DryRunContent string
}

func CreateModel

func CreateModel(cfg *Config, opt ...Level) *Model

CreateModel creates a model with the given configuration and optional level

Jump to

Keyboard shortcuts

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