cli

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayWelcome

func DisplayWelcome(config WelcomeConfig)

func EventLoop

func EventLoop(
	ctx context.Context,
	cancel context.CancelFunc,
	inputCh chan string,
	inputErrCh chan error,
	readyCh chan struct{},
	voiceInputCh chan string,
	audioStartCh, audioEndCh <-chan struct{},
	inputStream *audio.StreamHandler,
	log *logger.Logger,
	conversation chat.Conversation,
	renderer *term.Renderer,
	textToTextBackend baseprovider.TextToTextProvider,
	processInputFunc ProcessInputFuncT,
)

EventLoop manages the main event loop.

func GenerateCompletion

func GenerateCompletion(
	ctx context.Context,
	conversation chat.Conversation,
	renderer *term.Renderer,
	textToTextBackend baseprovider.TextToTextProvider,
) (string, error)

GenerateCompletion generates a completion using the provided backend.

func HandleCommands

func HandleCommands(text string, conversation chat.Conversation) string

func InitChatDatabase

func InitChatDatabase(sqlitePath string) (chat.Repository, error)

InitChatDatabase initializes the chat repository.

func InitCodeDatabase

func InitCodeDatabase(sqlitePath string) (code.Repository, error)

InitCodeDatabase initializes the code repository.

func InitConversation

func InitConversation(
	repo chat.Repository,
	conversationID *string,
	defaultPrompt prompts.Prompt,
) (chat.Conversation, error)

InitConversation initializes the conversation. If conversationID is nil, a new conversation is created.

func InitJSONProviders added in v0.2.0

func InitJSONProviders(
	logger *logger.Logger,
	targetModel string,
) (baseprovider.TextToJSONProvider, error)

InitJSONProviders initializes the text-to-json provider.

func InitTextProviders added in v0.2.0

func InitTextProviders(
	logger *logger.Logger,
	targetModel string,
	reasoning bool,
) (baseprovider.TextToTextProvider, error)

InitTextProviders initializes the text-to-text provider.

func InitTranscriptionServer

func InitTranscriptionServer(
	oaiKey string,
	audioOpts *audio.StreamParameters,
	log *logger.Logger,
	callback transcription.TranscriptionServerCallbackT,
	language string,
) (*transcription.TranscriptionServer, error)

InitTranscriptionServer initializes the Transcription Server with predefined buffer settings.

func InitVoice

func InitVoice(
	cfg *config.Config,
	log *logger.Logger,
	handleTranscription func(text string, isProcessing bool),
	cmdKeyCode uint16,
	language string,
) (*audio.StreamHandler, <-chan struct{}, <-chan struct{}, error)

func SetupKeyHooks

func SetupKeyHooks(
	cmdKeyCode uint16,
	ts *transcription.TranscriptionServer,
) (chan struct{}, chan struct{})

SetupKeyHooks sets up global key hooks for audio control.

Types

type Conversation

type Conversation interface {
	GetID() string
}

type ModelProvider

type ModelProvider interface {
	GetModel() string
}

type ProcessInputFuncT

TODO(nullswan): Refactor this to use a more generic function signature.

type WelcomeConfig

type WelcomeConfig struct {
	Conversation    Conversation
	Provider        []providers.AIProvider
	ModelProviders  []ModelProvider
	WelcomeMessage  string
	StartPrompt     *string
	BuildVersion    string
	BuildDate       string
	AdditionalLines []string
	Instructions    []string
}

func NewWelcomeConfig

func NewWelcomeConfig(
	conversation Conversation,
	opts ...WelcomeOption,
) WelcomeConfig

type WelcomeOption

type WelcomeOption func(*WelcomeConfig)

func WithAdditionalLine

func WithAdditionalLine(line string) WelcomeOption

func WithBuildDate

func WithBuildDate(date string) WelcomeOption

func WithBuildVersion

func WithBuildVersion(version string) WelcomeOption

func WithInstruction

func WithInstruction(instr string) WelcomeOption

func WithModelProvider

func WithModelProvider(mp ModelProvider) WelcomeOption

func WithProvider

func WithProvider(provider providers.AIProvider) WelcomeOption

func WithStartPrompt

func WithStartPrompt(prompt string) WelcomeOption

func WithWelcomeMessage

func WithWelcomeMessage(msg string) WelcomeOption

Jump to

Keyboard shortcuts

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