llm

package
v0.0.0-...-37de4d1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WaitForStream

func WaitForStream(ch <-chan tea.Msg) tea.Cmd

WaitForStream returns a Cmd that reads the next message from ch.

Types

type CategoryRule

type CategoryRule struct {
	Pattern  string
	Patterns []string
	Regex    bool
	Category string
}

CategoryRule is a single pattern → category mapping used by BulkSaveCategoryRules.

type Client

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

Client manages the Ollama conversation and executes tool calls.

func NewClient

func NewClient(model string, tools Tools, debug bool) *Client

NewClient creates a Client connected to the local Ollama instance.

func (*Client) Ask

func (c *Client) Ask(question string) tea.Cmd

Ask appends the user question to history and returns a Cmd that immediately delivers LLMStreamStartMsg. Content tokens arrive as LLMStreamMsg events, terminated by LLMStreamDoneMsg or LLMErrorMsg.

func (*Client) ClearHistory

func (c *Client) ClearHistory()

ClearHistory resets the conversation to just the system prompt.

type LLMDebugMsg

type LLMDebugMsg struct {
	Text string
}

LLMDebugMsg carries a single debug line describing an LLM roundtrip event.

type LLMErrorMsg

type LLMErrorMsg struct {
	Err error
}

LLMErrorMsg is returned when the LLM call fails.

type LLMStreamDoneMsg

type LLMStreamDoneMsg struct{}

LLMStreamDoneMsg signals the stream finished successfully.

type LLMStreamMsg

type LLMStreamMsg struct {
	Content string
}

LLMStreamMsg carries one chunk of text from the model's final response.

type LLMStreamStartMsg

type LLMStreamStartMsg struct {
	Ch <-chan tea.Msg
}

LLMStreamStartMsg is returned by Ask; it carries the channel that delivers subsequent stream events (LLMStreamMsg / LLMStreamDoneMsg / LLMErrorMsg).

type Tools

type Tools struct {
	GetUncategorizedTransactions func(offset int) []string
	GetTransactions              func(filters TransactionFilters) []string
	GetMonthlySummary            func(months []string) []string
	GetCategories                func() []string
	SaveCategoryRule             func(pattern, category string) error
	BulkSaveCategoryRules        func(rules []CategoryRule) (saved int, err error)
}

Tools holds callback functions the LLM can invoke. Each field is wired up by the caller (app.go) which owns the data.

type TransactionFilters

type TransactionFilters struct {
	Category string // filter by category name
	Month    string // "YYYY-MM" format, e.g. "2024-01"
	Type     string // "expense", "income", or "investment"
}

TransactionFilters holds optional filters for the GetTransactions tool.

Jump to

Keyboard shortcuts

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