api

package
v0.0.0-...-2bf20ed Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package api provides HTTP handlers and the main API server logic for PromptPipe.

It exposes RESTful endpoints for scheduling, sending, and tracking WhatsApp prompts. The API integrates with the WhatsApp, timer, and store modules.

Package api provides conversation participant management handlers for PromptPipe endpoints.

Package api provides HTTP handlers for PromptPipe endpoints.

Package api provides HTTP response utilities for PromptPipe.

Index

Constants

View Source
const (
	// DefaultServerAddress is the default HTTP server address
	DefaultServerAddress = ":8080"
	// DefaultShutdownTimeout is the default timeout for graceful server shutdown
	DefaultShutdownTimeout = 5 * time.Second
	// DefaultScheduledJobTimeout is the default timeout for scheduled job operations
	DefaultScheduledJobTimeout = 30 * time.Second
)

Default configuration constants

Variables

This section is empty.

Functions

func Run

func Run(waOpts []whatsapp.Option, storeOpts []store.Option, genaiOpts []genai.Option, apiOpts []Option) error

Run starts the API server and initializes dependencies, applying module options. It returns an error if initialization fails.

Types

type ContextKey

type ContextKey string

ContextKey is a custom type for context keys to avoid collisions

const (
	// ContextKeyParticipantID is the context key for participant ID
	ContextKeyParticipantID ContextKey = "participantID"
)

type Option

type Option func(*Opts)

Option defines a configuration option for the API server.

func WithAddr

func WithAddr(addr string) Option

WithAddr overrides the server address for the API.

func WithAutoFeedbackAfterPromptEnabled

func WithAutoFeedbackAfterPromptEnabled(enabled bool) Option

WithAutoFeedbackAfterPromptEnabled enables/disables auto feedback enforcement after scheduled prompts.

func WithChatHistoryLimit

func WithChatHistoryLimit(limit int) Option

WithChatHistoryLimit sets the limit for number of history messages sent to bot tools. -1: no limit, 0: no history, positive: limit to last N messages

func WithDebugMode

func WithDebugMode(enabled bool) Option

WithDebugMode enables debug mode for user-facing debug messages.

func WithDefaultCron

func WithDefaultCron(cron string) Option

WithDefaultCron overrides the default schedule for prompts using a cron-like format. This is a compatibility function that converts cron string to Schedule struct.

func WithDefaultSchedule

func WithDefaultSchedule(schedule *models.Schedule) Option

WithDefaultSchedule overrides the default schedule for prompts.

func WithFeedbackFollowupDelay

func WithFeedbackFollowupDelay(delay string) Option

WithFeedbackFollowupDelay sets the delay before follow-up feedback session.

func WithFeedbackInitialTimeout

func WithFeedbackInitialTimeout(timeout string) Option

WithFeedbackInitialTimeout sets the timeout for initial feedback response.

func WithFeedbackTrackerPromptFile

func WithFeedbackTrackerPromptFile(filePath string) Option

WithFeedbackTrackerPromptFile sets the path to the feedback tracker system prompt file.

func WithIntakeBotPromptFile

func WithIntakeBotPromptFile(filePath string) Option

WithIntakeBotPromptFile sets the path to the intake bot system prompt file.

func WithPromptGeneratorPromptFile

func WithPromptGeneratorPromptFile(filePath string) Option

WithPromptGeneratorPromptFile sets the path to the prompt generator system prompt file.

func WithSchedulerPrepTimeMinutes

func WithSchedulerPrepTimeMinutes(minutes int) Option

WithSchedulerPrepTimeMinutes sets the preparation time in minutes before scheduled habit reminders.

type Opts

type Opts struct {
	Addr                           string           // overrides API_ADDR
	DefaultSchedule                *models.Schedule // overrides DEFAULT_SCHEDULE
	IntakeBotPromptFile            string           // path to intake bot system prompt file
	PromptGeneratorPromptFile      string           // path to prompt generator system prompt file
	FeedbackTrackerPromptFile      string           // path to feedback tracker system prompt file
	ChatHistoryLimit               int              // limit for number of history messages sent to bot tools
	FeedbackInitialTimeout         string           // timeout for initial feedback response
	FeedbackFollowupDelay          string           // delay before follow-up feedback session
	DebugMode                      bool             // enable debug mode for user-facing debug messages
	SchedulerPrepTimeMinutes       int              // preparation time in minutes before scheduled habit reminders
	AutoFeedbackAfterPromptEnabled bool             // enable auto feedback session enforcement after scheduled prompt inactivity
}

Opts holds configuration options for the API server, such as HTTP address and default schedule.

type Server

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

Server holds all dependencies for the API server.

func NewServer

func NewServer(msgService messaging.Service, st store.Store, timer models.Timer, defaultSchedule *models.Schedule, gaClient *genai.Client) *Server

NewServer creates a new API server instance with the provided dependencies.

Jump to

Keyboard shortcuts

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