components

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

internal/components/registry.go Package components provides component registry and management for LocalCloud

Index

Constants

View Source
const (
	GB = 1024 * 1024 * 1024
	MB = 1024 * 1024
)

Variables

View Source
var ProjectTemplates = map[string]ProjectTemplate{
	"custom": {
		Name:        "Custom",
		Description: "Select components manually",
		Components:  []string{},
	},
	"rag": {
		Name:        "RAG Application",
		Description: "Retrieval-augmented generation with vector search",
		Components:  []string{"llm", "embedding", "database", "vector", "cache"},
	},
	"chatbot": {
		Name:        "Chatbot Application",
		Description: "Create conversational AI interfaces",
		Components:  []string{"llm", "database", "cache"},
	},
	"fullstack": {
		Name:        "Full Stack App",
		Description: "Complete application with all necessary components",
		Components:  []string{"llm", "database", "cache", "queue", "storage"},
	},
	"simple": {
		Name:        "Simple LLM",
		Description: "Just language model, no additional services",
		Components:  []string{"llm"},
	},
}

ProjectTemplates defines component sets for project types

View Source
var Registry = map[string]Component{
	"llm": {
		ID:          "llm",
		Name:        "LLM (Text generation)",
		Description: "Large language models for text generation, chat, and completion",
		Category:    "ai",
		Services:    []string{"ai"},
		Models: []Model{
			{Name: "qwen2.5:3b", Size: "2.3GB", RAM: 4 * GB, Default: true},
			{Name: "llama3.2:3b", Size: "2.0GB", RAM: 4 * GB},
			{Name: "deepseek-coder:1.3b", Size: "1.5GB", RAM: 3 * GB},
			{Name: "phi3:mini", Size: "2.3GB", RAM: 4 * GB},
			{Name: "gemma2:2b", Size: "1.6GB", RAM: 3 * GB},
		},
		MinRAM: 4 * GB,
	},
	"embedding": {
		ID:          "embedding",
		Name:        "Embeddings (Semantic search)",
		Description: "Text embeddings for semantic search and similarity",
		Category:    "ai",
		Services:    []string{"ai"},
		Models: []Model{
			{Name: "nomic-embed-text", Size: "274MB", RAM: 768 * MB, Dimensions: 768, Default: true},
			{Name: "mxbai-embed-large", Size: "670MB", RAM: 1 * GB, Dimensions: 1024},
			{Name: "all-minilm", Size: "46MB", RAM: 256 * MB, Dimensions: 384},
			{Name: "bge-small", Size: "134MB", RAM: 512 * MB, Dimensions: 384},
		},
		MinRAM: 2 * GB,
	},
	"database": {
		ID:          "database",
		Name:        "Database (PostgreSQL)",
		Description: "Standard relational database for data storage",
		Category:    "database",
		Services:    []string{"postgres"},
		MinRAM:      512 * MB,
	},
	"vector": {
		ID:          "vector",
		Name:        "Vector Search (pgvector)",
		Description: "Add vector similarity search to PostgreSQL",
		Category:    "database",
		Services:    []string{"postgres"},
		MinRAM:      512 * MB,
		Config: map[string]interface{}{
			"extension":  "pgvector",
			"depends_on": "database",
		},
	},
	"mongodb": {
		ID:          "mongodb",
		Name:        "NoSQL Database (MongoDB)",
		Description: "Document-oriented database for flexible data storage",
		Category:    "database",
		Services:    []string{"mongodb"},
		MinRAM:      1 * GB,
	},
	"cache": {
		ID:          "cache",
		Name:        "Cache (Redis)",
		Description: "In-memory cache for temporary data and sessions",
		Category:    "infrastructure",
		Services:    []string{"cache"},
		MinRAM:      512 * MB,
	},
	"queue": {
		ID:          "queue",
		Name:        "Queue (Redis)",
		Description: "Reliable job queue for background processing",
		Category:    "infrastructure",
		Services:    []string{"queue"},
		MinRAM:      512 * MB,
	},
	"storage": {
		ID:          "storage",
		Name:        "Object Storage (MinIO)",
		Description: "S3-compatible object storage for files and media",
		Category:    "infrastructure",
		Services:    []string{"minio"},
		MinRAM:      1 * GB,
	},
}

Registry holds all available components

Functions

func CalculateRAMRequirement

func CalculateRAMRequirement(componentIDs []string) int64

CalculateRAMRequirement calculates total RAM needed for components

func ComponentsToServices

func ComponentsToServices(componentIDs []string) []string

ComponentsToServices converts component IDs to required services

func GetComponentDependencies added in v0.2.0

func GetComponentDependencies(componentID string) []string

GetComponentDependencies returns required components for a given component

func GetDependentComponents added in v0.2.0

func GetDependentComponents(componentID string, enabledComponents []string) []string

GetDependentComponents returns components that depend on the given component

func IsAIComponent

func IsAIComponent(id string) bool

IsAIComponent returns true if the component requires AI models

func ValidateComponentDependencies added in v0.2.0

func ValidateComponentDependencies(componentIDs []string) error

ValidateComponentDependencies checks if component dependencies are satisfied

Types

type Component

type Component struct {
	ID          string
	Name        string
	Description string
	Category    string                 // "ai", "database", "infrastructure"
	Services    []string               // Required docker services
	Models      []Model                // Available models (for AI components)
	MinRAM      int64                  // Minimum RAM requirement
	Config      map[string]interface{} // Additional configuration
}

Component represents a LocalCloud component

func GetAllComponents added in v0.2.0

func GetAllComponents() []Component

GetAllComponents returns all available components

func GetComponent

func GetComponent(id string) (Component, error)

GetComponent returns a component by ID

func GetComponentsByCategory

func GetComponentsByCategory(category string) []Component

GetComponentsByCategory returns all components in a category

type Model added in v0.2.0

type Model struct {
	Name       string
	Size       string
	RAM        int64
	Default    bool
	Dimensions int    // For embedding models
	Family     string // Model family (e.g., "bert", "llama")
}

Model represents an AI model option for a component This is the type name used throughout the codebase

type ProjectTemplate

type ProjectTemplate struct {
	Name        string
	Description string
	Components  []string
}

ProjectTemplate represents a project type with preset components

func GetTemplate

func GetTemplate(name string) (ProjectTemplate, error)

GetTemplate returns a project template by name

Jump to

Keyboard shortcuts

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