suggestions

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 7 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 {
	CacheTTL  time.Duration
	Templates []Template
}

Config holds configuration for the SuggestionEngine.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a SuggestionEngine config with sensible defaults.

type Handler

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

Handler provides HTTP handlers for the suggestions API.

func NewHandler

func NewHandler(engine *SuggestionEngine) *Handler

NewHandler creates a new suggestions API handler.

func (*Handler) HandleGetSuggestions

func (h *Handler) HandleGetSuggestions(w http.ResponseWriter, r *http.Request)

HandleGetSuggestions handles GET /api/conversations/{id}/suggestions. Returns cached suggestions or template-based fallback.

func (*Handler) HandleGetSuggestionsWithMessages

func (h *Handler) HandleGetSuggestionsWithMessages(w http.ResponseWriter, r *http.Request)

HandleGetSuggestionsWithMessages handles POST /api/conversations/{id}/suggestions. Generates fresh suggestions from the provided messages.

func (*Handler) HandleInvalidateCache

func (h *Handler) HandleInvalidateCache(w http.ResponseWriter, r *http.Request)

HandleInvalidateCache handles DELETE /api/conversations/{id}/suggestions/cache.

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers the suggestions API routes on a ServeMux.

type LLMProvider

type LLMProvider interface {
	GenerateSuggestions(ctx context.Context, systemPrompt, userPrompt string) ([]Suggestion, error)
}

LLMProvider abstracts the AI generation backend for suggestions.

type Message

type Message struct {
	ID        string    `json:"id"`
	Body      string    `json:"body"`
	Role      string    `json:"role"` // "counselor", "texter", "system"
	Timestamp time.Time `json:"timestamp"`
}

Message represents a single conversation message for generating suggestions.

type Suggestion

type Suggestion struct {
	Text       string  `json:"text"`
	Category   string  `json:"category"` // "empathy", "question", "resource", "safety", "reframe"
	Confidence float64 `json:"confidence"`
	Reasoning  string  `json:"reasoning,omitempty"`
}

Suggestion represents a response suggestion for a counselor.

type SuggestionEngine

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

SuggestionEngine generates response suggestions for conversations.

func NewSuggestionEngine

func NewSuggestionEngine(provider LLMProvider, cfg Config) *SuggestionEngine

NewSuggestionEngine creates a new SuggestionEngine. If provider is nil, only template-based fallback suggestions are available.

func (*SuggestionEngine) ClearCache

func (e *SuggestionEngine) ClearCache()

ClearCache removes all cached suggestions.

func (*SuggestionEngine) GetSuggestions

func (e *SuggestionEngine) GetSuggestions(ctx context.Context, conversationID string, messages []Message) ([]Suggestion, error)

GetSuggestions returns response suggestions for a conversation. If the LLM provider is unavailable, it falls back to template-based suggestions.

func (*SuggestionEngine) InvalidateConversation

func (e *SuggestionEngine) InvalidateConversation(conversationID string)

InvalidateConversation removes cached suggestions for a specific conversation.

type Template

type Template struct {
	Category string   `json:"category"`
	Patterns []string `json:"patterns"` // keywords that trigger this template
	Texts    []string `json:"texts"`    // response options
}

Template defines a fallback response template.

Jump to

Keyboard shortcuts

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