autocomplete

package
v0.2.27 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package autocomplete provides LLM-powered ghost text suggestions for task input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service handles autocomplete requests with debouncing and cancellation.

func NewService

func NewService(apiKey string) *Service

NewService creates a new autocomplete service. apiKey can be empty - it will check ANTHROPIC_API_KEY env var.

func (*Service) Cancel

func (s *Service) Cancel()

Cancel is a no-op - cancellation is handled via context.

func (*Service) GenerateTitle

func (s *Service) GenerateTitle(ctx context.Context, body, project string) (string, error)

GenerateTitle generates a concise task title from the description/body. This is used when the user provides a description but no title.

func (*Service) GetSuggestion

func (s *Service) GetSuggestion(ctx context.Context, input, fieldType, project, extraContext string, recentTasks []string) *Suggestion

GetSuggestion gets an autocomplete suggestion for the given input. This is a blocking call that should be run in a goroutine. Returns nil if cancelled, timed out, or no good suggestion. The context should be cancelled if the user continues typing. recentTasks provides context about recent task titles for better suggestions.

func (*Service) IsAvailable

func (s *Service) IsAvailable() bool

IsAvailable returns true if the autocomplete service has an API key configured.

func (*Service) Warmup

func (s *Service) Warmup()

Warmup pre-warms the HTTP connection by making a lightweight API request. This establishes the TLS connection so subsequent requests are faster.

type Suggestion

type Suggestion struct {
	Text      string // The suggested completion text (suffix to append)
	FullText  string // The full text including user input + suggestion
	RequestID int64  // To match responses with requests
}

Suggestion represents a completion suggestion from the LLM.

Jump to

Keyboard shortcuts

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