ai

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const SystemPrompt = `` /* 7529-byte string literal not displayed */

Variables

This section is empty.

Functions

func BuildPromptWithContext

func BuildPromptWithContext(memories []string, calendarEvents []string, currentTime string) string

BuildPromptWithContext injects memory, calendar, and current time into the system prompt

Types

type AIResponse

type AIResponse struct {
	Actions  []Action `json:"actions"`
	Response struct {
		Text    string `json:"text"`
		Emotion string `json:"emotion"`
	} `json:"response"`
}

AIResponse represents the structured response from the AI

type Action

type Action struct {
	Type string                 `json:"type"`
	Data map[string]interface{} `json:"data"`
}

Action represents an action to be executed

type CalendarEvent

type CalendarEvent struct {
	Title     string
	StartTime time.Time
	EndTime   time.Time
	Location  string
}

CalendarEvent represents a calendar event for AI context

type CalendarProvider

type CalendarProvider interface {
	ListEvents(ctx context.Context) ([]*CalendarEvent, error)
	IsInitialized() bool
}

CalendarProvider interface for fetching calendar events

type OllamaManager

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

OllamaManager manages the lifecycle of a bundled Ollama binary.

func NewOllamaManager

func NewOllamaManager(appDir string) *OllamaManager

NewOllamaManager creates a new Ollama manager. appDir should be the application data directory.

func (*OllamaManager) EnsureModel

func (m *OllamaManager) EnsureModel(model string) error

EnsureModel pulls a model if it's not already available.

func (*OllamaManager) GetURL

func (m *OllamaManager) GetURL() string

GetURL returns the Ollama API URL.

func (*OllamaManager) IsRunning

func (m *OllamaManager) IsRunning() bool

IsRunning returns whether Ollama is currently running.

func (*OllamaManager) Start

func (m *OllamaManager) Start(ctx context.Context) error

Start starts the Ollama server.

func (*OllamaManager) Stop

func (m *OllamaManager) Stop() error

Stop stops the Ollama server.

type ResponsePayload

type ResponsePayload struct {
	Text    string `json:"text"`
	Emotion string `json:"emotion"`
}

ResponsePayload for returning to WebSocket

type Service

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

Service handles AI interactions via requesty.ai

func NewService

func NewService(cfg *config.Config, memoryStore *memory.Store) *Service

NewService creates a new AI service

func (*Service) GenerateEmbedding

func (s *Service) GenerateEmbedding(ctx context.Context, text string) ([]float32, error)

GenerateEmbedding creates a vector embedding for the given text using local Ollama. Returns a 768-dimensional vector suitable for pgvector storage.

func (*Service) ProcessCommand

func (s *Service) ProcessCommand(text string) (*ResponsePayload, []Action, error)

ProcessCommand sends a command to the AI and returns the response

func (*Service) ProcessCommandStream

func (s *Service) ProcessCommandStream(text string, onChunk StreamCallback) (*ResponsePayload, []Action, error)

ProcessCommandStream sends a command and streams the response

func (*Service) ProcessCommandWithHistory

func (s *Service) ProcessCommandWithHistory(text string, history []openai.ChatCompletionMessage) (*ResponsePayload, []Action, error)

ProcessCommandWithHistory processes with conversation history

func (*Service) SetCalendar

func (s *Service) SetCalendar(cal CalendarProvider)

SetCalendar sets the calendar provider (called after calendar service is created)

type StreamCallback

type StreamCallback func(chunk string, done bool)

StreamCallback is called for each chunk of streamed response

Jump to

Keyboard shortcuts

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