chat

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Model      string
	MaxResults int // top-K messages to include (default: 20)
	MaxBodyLen int // truncate body per message (default: 2000 chars)
}

Config holds chat session configuration.

type LLMClient

type LLMClient interface {
	// ChatStream sends messages and streams response tokens via callback.
	ChatStream(ctx context.Context, messages []Message, onToken func(string)) error
	// Chat sends messages and returns the complete response.
	Chat(ctx context.Context, messages []Message) (string, error)
}

LLMClient abstracts LLM providers for swappability.

type Message

type Message struct {
	Role    string // "system", "user", "assistant"
	Content string
}

Message represents a chat message.

type OllamaClient

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

OllamaClient implements LLMClient using the Ollama API.

func NewOllamaClient

func NewOllamaClient(serverURL, model string) (*OllamaClient, error)

NewOllamaClient creates an OllamaClient for the given server and model.

func (*OllamaClient) Chat

func (o *OllamaClient) Chat(ctx context.Context, messages []Message) (string, error)

func (*OllamaClient) ChatStream

func (o *OllamaClient) ChatStream(ctx context.Context, messages []Message, onToken func(string)) error

type RetrievedMessage

type RetrievedMessage struct {
	ID      int64
	From    string
	To      string
	Date    string
	Subject string
	Labels  string
	Body    string
}

RetrievedMessage holds a message formatted for context injection.

type Session

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

Session manages a chat conversation with RAG over the email archive.

func NewSession

func NewSession(engine query.Engine, llm LLMClient, cfg Config) *Session

NewSession creates a new chat session.

func (*Session) Ask

func (s *Session) Ask(ctx context.Context, userQuestion string) error

Ask processes a user question: plans a query, retrieves messages, and streams an answer.

Jump to

Keyboard shortcuts

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