components

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 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{
	"rag": {
		Name:        "RAG/Knowledge Base",
		Description: "Build AI-powered search and Q&A systems",
		Components:  []string{"llm", "embedding", "vector", "cache"},
	},
	"chatbot": {
		Name:        "Chatbot Application",
		Description: "Create conversational AI interfaces",
		Components:  []string{"llm", "cache"},
	},

	"api": {
		Name:        "API Service",
		Description: "AI-powered REST API backend",
		Components:  []string{"llm", "cache", "queue"},
	},
	"custom": {
		Name:        "Custom",
		Description: "Select components manually",
		Components:  []string{},
	},
}

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: []ModelOption{
			{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: []ModelOption{
			{Name: "nomic-embed-text", Size: "274MB", Dimensions: 768, Default: true},
			{Name: "mxbai-embed-large", Size: "670MB", Dimensions: 1024},
			{Name: "all-minilm", Size: "46MB", Dimensions: 384},
			{Name: "bge-small", Size: "134MB", Dimensions: 384},
		},
		MinRAM: 2 * GB,
	},

	"vector": {
		ID:          "vector",
		Name:        "Vector Database (pgvector)",
		Description: "PostgreSQL with pgvector for similarity search",
		Category:    "database",
		Services:    []string{"postgres"},
		MinRAM:      1 * GB,
		Config: map[string]interface{}{
			"extensions": []string{"pgvector"},
		},
	},
	"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 IsAIComponent

func IsAIComponent(id string) bool

IsAIComponent returns true if the component requires AI models

Types

type Component

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

Component represents a LocalCloud component

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 ModelOption

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

ModelOption represents an AI model option for a component

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