internal

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client handles HTTP communication with OpenAI-compatible APIs.

func NewClient

func NewClient(apiKey, baseURL string) (*Client, error)

NewClient creates a new API client.

func NewSecureClient added in v0.4.0

func NewSecureClient(apiKey, baseURL string) (*Client, error)

NewSecureClient creates a new secure API client with enhanced security features

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, messages []Message, model string, temperature float64) (string, error)

Chat sends a chat completion request and returns the assistant's response.

func (*Client) ChatStream

func (c *Client) ChatStream(ctx context.Context, messages []Message, model string, temperature float64, onChunk func(string) error) error

ChatStream sends a streaming chat completion request and calls onChunk for each content delta.

func (*Client) GetRateLimitStats added in v0.4.0

func (c *Client) GetRateLimitStats() (requests int, remainingTime time.Duration, allowed bool)

GetRateLimitStats returns rate limiting statistics for the client

func (*Client) GetTokenBucketTokens added in v0.4.0

func (c *Client) GetTokenBucketTokens() int

GetTokenBucketTokens returns the current number of tokens in the bucket

func (*Client) ResetRateLimiter added in v0.4.0

func (c *Client) ResetRateLimiter()

ResetRateLimiter resets the rate limiter for this client

type CommandHandler added in v0.3.1

type CommandHandler interface {
	Process(ctx context.Context, parts []string) (exit bool, err error)
	Name() string
	Aliases() []string
	HelpText() string
	Usage() string
	MinArgs() int
}

CommandHandler defines the interface for command handlers. CommandHandler interface for processing chat commands

type CommandRegistry added in v0.3.1

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

CommandRegistry maps command names to their handlers.

type ExitCommandHandler added in v0.4.0

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

ExitCommandHandler handles the exit command

func (*ExitCommandHandler) Aliases added in v0.4.0

func (h *ExitCommandHandler) Aliases() []string

func (*ExitCommandHandler) HelpText added in v0.4.0

func (h *ExitCommandHandler) HelpText() string

func (*ExitCommandHandler) MinArgs added in v0.4.0

func (h *ExitCommandHandler) MinArgs() int

func (*ExitCommandHandler) Name added in v0.4.0

func (h *ExitCommandHandler) Name() string

func (*ExitCommandHandler) Process added in v0.4.0

func (h *ExitCommandHandler) Process(ctx context.Context, parts []string) (exit bool, err error)

func (*ExitCommandHandler) Usage added in v0.4.0

func (h *ExitCommandHandler) Usage() string

type HelpCommandHandler added in v0.4.0

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

HelpCommandHandler handles the help command

func (*HelpCommandHandler) Aliases added in v0.4.0

func (h *HelpCommandHandler) Aliases() []string

func (*HelpCommandHandler) HelpText added in v0.4.0

func (h *HelpCommandHandler) HelpText() string

func (*HelpCommandHandler) MinArgs added in v0.4.0

func (h *HelpCommandHandler) MinArgs() int

func (*HelpCommandHandler) Name added in v0.4.0

func (h *HelpCommandHandler) Name() string

func (*HelpCommandHandler) Process added in v0.4.0

func (h *HelpCommandHandler) Process(ctx context.Context, parts []string) (exit bool, err error)

func (*HelpCommandHandler) Usage added in v0.4.0

func (h *HelpCommandHandler) Usage() string

type HistoryCommandHandler added in v0.4.0

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

HistoryCommandHandler handles the history command

func (*HistoryCommandHandler) Aliases added in v0.4.0

func (h *HistoryCommandHandler) Aliases() []string

func (*HistoryCommandHandler) HelpText added in v0.4.0

func (h *HistoryCommandHandler) HelpText() string

func (*HistoryCommandHandler) MinArgs added in v0.4.0

func (h *HistoryCommandHandler) MinArgs() int

func (*HistoryCommandHandler) Name added in v0.4.0

func (h *HistoryCommandHandler) Name() string

func (*HistoryCommandHandler) Process added in v0.4.0

func (h *HistoryCommandHandler) Process(ctx context.Context, parts []string) (exit bool, err error)

func (*HistoryCommandHandler) Usage added in v0.4.0

func (h *HistoryCommandHandler) Usage() string

type ListCommandHandler added in v0.4.0

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

ListCommandHandler handles the list command

func (*ListCommandHandler) Aliases added in v0.4.0

func (h *ListCommandHandler) Aliases() []string

func (*ListCommandHandler) HelpText added in v0.4.0

func (h *ListCommandHandler) HelpText() string

func (*ListCommandHandler) MinArgs added in v0.4.0

func (h *ListCommandHandler) MinArgs() int

func (*ListCommandHandler) Name added in v0.4.0

func (h *ListCommandHandler) Name() string

func (*ListCommandHandler) Process added in v0.4.0

func (h *ListCommandHandler) Process(ctx context.Context, parts []string) (exit bool, err error)

func (*ListCommandHandler) Usage added in v0.4.0

func (h *ListCommandHandler) Usage() string

type LoadCommandHandler added in v0.4.0

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

LoadCommandHandler handles the load command

func (*LoadCommandHandler) Aliases added in v0.4.0

func (h *LoadCommandHandler) Aliases() []string

func (*LoadCommandHandler) HelpText added in v0.4.0

func (h *LoadCommandHandler) HelpText() string

func (*LoadCommandHandler) MinArgs added in v0.4.0

func (h *LoadCommandHandler) MinArgs() int

func (*LoadCommandHandler) Name added in v0.4.0

func (h *LoadCommandHandler) Name() string

func (*LoadCommandHandler) Process added in v0.4.0

func (h *LoadCommandHandler) Process(ctx context.Context, parts []string) (exit bool, err error)

func (*LoadCommandHandler) Usage added in v0.4.0

func (h *LoadCommandHandler) Usage() string

type MarkdownCommandHandler added in v0.4.0

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

MarkdownCommandHandler handles the markdown command

func (*MarkdownCommandHandler) Aliases added in v0.4.0

func (h *MarkdownCommandHandler) Aliases() []string

func (*MarkdownCommandHandler) HelpText added in v0.4.0

func (h *MarkdownCommandHandler) HelpText() string

func (*MarkdownCommandHandler) MinArgs added in v0.4.0

func (h *MarkdownCommandHandler) MinArgs() int

func (*MarkdownCommandHandler) Name added in v0.4.0

func (h *MarkdownCommandHandler) Name() string

func (*MarkdownCommandHandler) Process added in v0.4.0

func (h *MarkdownCommandHandler) Process(ctx context.Context, parts []string) (exit bool, err error)

func (*MarkdownCommandHandler) Usage added in v0.4.0

func (h *MarkdownCommandHandler) Usage() string

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message represents a single chat message.

type ResetCommandHandler added in v0.4.0

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

ResetCommandHandler handles the reset command

func (*ResetCommandHandler) Aliases added in v0.4.0

func (h *ResetCommandHandler) Aliases() []string

func (*ResetCommandHandler) HelpText added in v0.4.0

func (h *ResetCommandHandler) HelpText() string

func (*ResetCommandHandler) MinArgs added in v0.4.0

func (h *ResetCommandHandler) MinArgs() int

func (*ResetCommandHandler) Name added in v0.4.0

func (h *ResetCommandHandler) Name() string

func (*ResetCommandHandler) Process added in v0.4.0

func (h *ResetCommandHandler) Process(ctx context.Context, parts []string) (exit bool, err error)

func (*ResetCommandHandler) Usage added in v0.4.0

func (h *ResetCommandHandler) Usage() string

type Session

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

Session manages a chat conversation with history.

func NewSession

func NewSession(client *Client, cfg *config.Config, store *storage.Store, version string) (*Session, error)

NewSession creates a new chat session.

func (*Session) DisableColors

func (s *Session) DisableColors()

DisableColors turns off ANSI color output.

func (*Session) Run

func (s *Session) Run(ctx context.Context) error

Run starts the interactive chat loop.

func (*Session) SetIO

func (s *Session) SetIO(in io.Reader, out io.Writer)

SetIO overrides input/output streams (useful for testing).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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