llm

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDisabled = errors.New("llm disabled")
)
View Source
var (
	ErrInvalidContextIndex = fmt.Errorf("invalid context index")
)

Functions

This section is empty.

Types

type LLM

type LLM struct {
	Client *openai.Client
	Model  string

	ContextManger TalkContextManager
}

func (*LLM) Msg

func (i *LLM) Msg(ctx context.Context, f features.ServerFeatures, message string, out *os.File) error

type LastByteDetector

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

func (*LastByteDetector) LastByte

func (d *LastByteDetector) LastByte() byte

func (*LastByteDetector) TotalBytes

func (d *LastByteDetector) TotalBytes() int64

func (*LastByteDetector) Write

func (d *LastByteDetector) Write(p []byte) (n int, err error)

type TalkContext

type TalkContext struct {
	Messages []openai.ChatCompletionMessageParamUnion `json:"messages"`
}

func (*TalkContext) IsEmpty added in v0.2.1

func (t *TalkContext) IsEmpty() bool

IsEmpty checks if the TalkContext has no messages.

type TalkContextInfo

type TalkContextInfo struct {
	Index   int
	Title   string
	Current bool
}

type TalkContextManager

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

TalkContextManager manages multiple TalkContexts.

func (*TalkContextManager) Clear

func (m *TalkContextManager) Clear()

Clear clears the messages of the current context.

func (*TalkContextManager) Current

func (m *TalkContextManager) Current() *TalkContext

Current returns the current TalkContext, creating a new one if none exists.

func (*TalkContextManager) Delete

func (m *TalkContextManager) Delete(index int) error

Delete removes a context by index and adjusts the current context if necessary.

func (*TalkContextManager) List

func (m *TalkContextManager) List() []*TalkContextInfo

List returns a list of TalkContextInfo for all contexts, including the current one.

func (*TalkContextManager) Load

func (m *TalkContextManager) Load(store string) error

Load contexts from file

func (*TalkContextManager) LoadOnce

func (m *TalkContextManager) LoadOnce(store string) (err error)

LoadOnce loads the contexts from the store only once, using sync.Once to ensure it is only done once.

func (*TalkContextManager) New

func (m *TalkContextManager) New()

New creates a new TalkContext and sets it as the current context.

func (*TalkContextManager) Pop added in v0.2.1

Pop removes the last message from the current TalkContext.

func (*TalkContextManager) Save

func (m *TalkContextManager) Save(store string) error

Save contexts to file

func (*TalkContextManager) SwitchTo

func (m *TalkContextManager) SwitchTo(index int) error

SwitchTo switches the current context to the one at the specified index.

Jump to

Keyboard shortcuts

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