ai

package
v0.62.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatResponse

type ChatResponse struct {
	Content   string
	ToolCalls []ToolCall
}

ChatResponse represents the LLM response including potential tool calls.

type Config

type Config struct {
	Embedding        EmbeddingConfig
	Reranker         RerankerConfig
	IntentClassifier IntentClassifierConfig
	LLM              LLMConfig
	Enabled          bool
}

Config represents AI configuration.

func NewConfigFromProfile

func NewConfigFromProfile(p *profile.Profile) *Config

NewConfigFromProfile creates AI config from profile.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type EmbeddingConfig

type EmbeddingConfig struct {
	Provider   string
	Model      string
	APIKey     string
	BaseURL    string
	Dimensions int
}

EmbeddingConfig represents vector embedding configuration.

type EmbeddingService

type EmbeddingService interface {
	// Embed generates vector for a single text.
	Embed(ctx context.Context, text string) ([]float32, error)

	// EmbedBatch generates vectors for multiple texts.
	EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)

	// Dimensions returns the vector dimension.
	Dimensions() int
}

EmbeddingService is the vector embedding service interface.

func NewEmbeddingService

func NewEmbeddingService(cfg *EmbeddingConfig) (EmbeddingService, error)

NewEmbeddingService creates a new EmbeddingService.

type FunctionCall

type FunctionCall struct {
	Name      string
	Arguments string
}

FunctionCall represents the function details.

type IntentClassifierConfig

type IntentClassifierConfig struct {
	Model   string
	APIKey  string
	BaseURL string
	Enabled bool
}

IntentClassifierConfig represents intent classification LLM configuration. Uses a lightweight model for fast, cost-effective classification.

type LLMConfig

type LLMConfig struct {
	Provider    string // deepseek, openai, ollama
	Model       string // deepseek-chat
	APIKey      string
	BaseURL     string
	MaxTokens   int     // default: 2048
	Temperature float32 // default: 0.7
}

LLMConfig represents LLM configuration.

type LLMService

type LLMService interface {
	// Chat performs synchronous chat.
	Chat(ctx context.Context, messages []Message) (string, error)

	// ChatStream performs streaming chat.
	ChatStream(ctx context.Context, messages []Message) (<-chan string, <-chan error)

	// ChatWithTools performs chat with function calling support.
	ChatWithTools(ctx context.Context, messages []Message, tools []ToolDescriptor) (*ChatResponse, error)
}

LLMService is the LLM service interface.

func NewLLMService

func NewLLMService(cfg *LLMConfig) (LLMService, error)

NewLLMService creates a new LLMService.

type Message

type Message struct {
	Role    string // system, user, assistant
	Content string
}

Message represents a chat message.

func AssistantMessage

func AssistantMessage(content string) Message

Helper for creating assistant messages.

func FormatMessages

func FormatMessages(systemPrompt string, userContent string, history []Message) []Message

FormatMessages formats messages for prompt templates.

func SystemPrompt

func SystemPrompt(content string) Message

Helper for creating system prompts.

func UserMessage

func UserMessage(content string) Message

Helper for creating user messages.

type RerankResult

type RerankResult struct {
	Index int     // Original index
	Score float32 // Relevance score
}

RerankResult represents a reranking result.

type RerankerConfig

type RerankerConfig struct {
	Provider string
	Model    string
	APIKey   string
	BaseURL  string
	Enabled  bool
}

RerankerConfig represents reranker configuration.

type RerankerService

type RerankerService interface {
	// Rerank reorders documents by relevance.
	Rerank(ctx context.Context, query string, documents []string, topN int) ([]RerankResult, error)

	// IsEnabled returns whether the service is enabled.
	IsEnabled() bool
}

RerankerService is the reranking service interface.

func NewRerankerService

func NewRerankerService(cfg *RerankerConfig) RerankerService

NewRerankerService creates a new RerankerService.

type ToolCall

type ToolCall struct {
	ID       string
	Type     string
	Function FunctionCall
}

ToolCall represents a request to call a tool.

type ToolDescriptor

type ToolDescriptor struct {
	Name        string
	Description string
	Parameters  string // JSON Schema string
}

ToolDescriptor represents a function/tool available to the LLM.

Directories

Path Synopsis
Package agent provides conversation context management for multi-turn dialogues.
Package agent provides conversation context management for multi-turn dialogues.
tools
Package tools provides resilient tool execution for AI agents.
Package tools provides resilient tool execution for AI agents.
Package aitime provides the time parsing service interface for AI agents.
Package aitime provides the time parsing service interface for AI agents.
Package cache provides the cache service interface for AI agents.
Package cache provides the cache service interface for AI agents.
Package context provides context building for LLM prompts.
Package context provides context building for LLM prompts.
Package duplicate provides memo duplicate detection for P2-C002.
Package duplicate provides memo duplicate detection for P2-C002.
Package genui provides Generative UI components for AI agents.
Package genui provides Generative UI components for AI agents.
Package graph - builder implementation for P3-C001.
Package graph - builder implementation for P3-C001.
Package habit provides user habit learning and analysis for AI agents.
Package habit provides user habit learning and analysis for AI agents.
Package memory provides the unified memory service interface for AI agents.
Package memory provides the unified memory service interface for AI agents.
Package metrics provides the evaluation metrics service interface for AI agents.
Package metrics provides the evaluation metrics service interface for AI agents.
Package prediction provides predictive interaction capabilities for AI agents.
Package prediction provides predictive interaction capabilities for AI agents.
Package rag provides Self-RAG optimization.
Package rag provides Self-RAG optimization.
Package reminder provides reminder management for schedules and todos.
Package reminder provides reminder management for schedules and todos.
Package review provides intelligent memo review system based on spaced repetition.
Package review provides intelligent memo review system based on spaced repetition.
Package router provides the LLM routing service.
Package router provides the LLM routing service.
Package schedule provides schedule-related AI agent utilities.
Package schedule provides schedule-related AI agent utilities.
Package session provides the session persistence service interface for AI agents.
Package session provides the session persistence service interface for AI agents.
Package tags provides intelligent tag suggestion for memos.
Package tags provides intelligent tag suggestion for memos.
Package timeout defines centralized timeout constants for AI operations.
Package timeout defines centralized timeout constants for AI operations.
Package vector provides the vector retrieval service interface for AI agents.
Package vector provides the vector retrieval service interface for AI agents.

Jump to

Keyboard shortcuts

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