handler

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeminiQuery

type GeminiQuery struct {
	*IO
	// contains filtered or unexported fields
}

GeminiQuery processes queries to gemini models. It implements the MessageHandler interface.

func NewGeminiQuery

func NewGeminiQuery(io *IO, session *gemini.ChatSession, opts RendererOptions) (*GeminiQuery, error)

NewGeminiQuery returns a new GeminiQuery message handler.

func (*GeminiQuery) Handle

func (h *GeminiQuery) Handle(message string) (Response, bool)

Handle processes the chat message.

type HelpCommand

type HelpCommand struct {
	*IO
	// contains filtered or unexported fields
}

HelpCommand handles the help system command request.

func NewHelpCommand

func NewHelpCommand(io *IO, opts RendererOptions) (*HelpCommand, error)

NewHelpCommand returns a new HelpCommand.

func (*HelpCommand) Handle

func (h *HelpCommand) Handle(_ string) (Response, bool)

Handle processes the help system command.

type HistoryCommand

type HistoryCommand struct {
	*IO
	// contains filtered or unexported fields
}

HistoryCommand processes the chat history system commands. It implements the MessageHandler interface.

func NewHistoryCommand

func NewHistoryCommand(io *IO, session *gemini.ChatSession,
	configuration *config.Configuration) *HistoryCommand

NewHistoryCommand returns a new HistoryCommand.

func (*HistoryCommand) Handle

func (h *HistoryCommand) Handle(_ string) (Response, bool)

Handle processes the history system command.

type IO

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

IO encapsulates terminal details for handlers.

func NewIO

func NewIO(terminal *terminal.IO, terminalPrompt string) *IO

NewIO returns a new IO.

func (*IO) TerminalPrompt

func (io *IO) TerminalPrompt() string

TerminalPrompt returns the terminal prompt string.

type InputModeCommand

type InputModeCommand struct {
	*IO
}

InputModeCommand processes the chat input mode system command. It implements the MessageHandler interface.

func NewInputModeCommand

func NewInputModeCommand(io *IO) *InputModeCommand

NewInputModeCommand returns a new InputModeCommand.

func (*InputModeCommand) Handle

func (h *InputModeCommand) Handle(_ string) (Response, bool)

Handle processes the chat input mode system command.

type MessageHandler

type MessageHandler interface {
	// Handle processes the message and returns a response, along with a flag
	// indicating whether the application should terminate.
	Handle(message string) (Response, bool)

	// TerminalPrompt returns the terminal prompt for the handler.
	TerminalPrompt() string
}

MessageHandler handles chat messages from the user.

type ModelCommand

type ModelCommand struct {
	*IO
	// contains filtered or unexported fields
}

ModelCommand processes the chat model system commands. It implements the MessageHandler interface.

func NewModelCommand

func NewModelCommand(io *IO, session *gemini.ChatSession, modelName string) *ModelCommand

NewModelCommand returns a new ModelCommand.

func (*ModelCommand) Handle

func (h *ModelCommand) Handle(_ string) (Response, bool)

Handle processes the chat model system command.

type QuitCommand

type QuitCommand struct {
	*IO
}

QuitCommand processes the chat quit system command. It implements the MessageHandler interface.

func NewQuitCommand

func NewQuitCommand(io *IO) *QuitCommand

NewQuitCommand returns a new QuitCommand.

func (*QuitCommand) Handle

func (h *QuitCommand) Handle(_ string) (Response, bool)

Handle processes the chat quit command.

type RendererOptions

type RendererOptions struct {
	StylePath string
	WordWrap  int
}

RendererOptions represents configuration options for the terminal renderer.

type Response

type Response interface {
	fmt.Stringer
}

Response represents a response from a chat message handler.

type SystemCommand

type SystemCommand struct {
	*IO
	// contains filtered or unexported fields
}

SystemCommand processes chat system commands; implements the MessageHandler interface. It aggregates the processing by delegating it to one of the underlying handlers.

func NewSystemCommand

func NewSystemCommand(io *IO, session *gemini.ChatSession, configuration *config.Configuration,
	modelName string, rendererOptions RendererOptions) (*SystemCommand, error)

NewSystemCommand returns a new SystemCommand.

func (*SystemCommand) Handle

func (s *SystemCommand) Handle(message string) (Response, bool)

Handle processes the chat system command.

type SystemPromptCommand

type SystemPromptCommand struct {
	*IO
	// contains filtered or unexported fields
}

SystemPromptCommand processes the chat prompt system command. It implements the MessageHandler interface.

func NewSystemPromptCommand

func NewSystemPromptCommand(io *IO, session *gemini.ChatSession,
	applicationData *config.ApplicationData) *SystemPromptCommand

NewSystemPromptCommand returns a new SystemPromptCommand.

func (*SystemPromptCommand) Handle

func (h *SystemPromptCommand) Handle(_ string) (Response, bool)

Handle processes the chat prompt system command.

Jump to

Keyboard shortcuts

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