feat: add logic_level and primary_use metadata to model groups
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

Schema: Added logic_level (INTEGER) and primary_use (TEXT) columns
to model_groups table with auto-migration for existing databases.

Seed: Three new default groups:
  heavy-logic  (level 9) — Complex Coding, Logic, Agents
  standard-pro (level 5) — General Assistant, Long Docs
  fast-flow    (level 2) — Classification, JSON, Basic Q&A

Admin API: INSERT/UPDATE handlers now accept and persist the new fields.
Dashboard: Table shows Level and Primary Use columns; form includes
both fields with appropriate inputs and placeholders.
This commit is contained in:
2026-05-07 12:01:28 -04:00
parent 79dd122b56
commit a3a6f765e7
3 changed files with 45 additions and 11 deletions
+21 -5
View File
@@ -130,6 +130,8 @@ func (db *DB) RunMigrations() error {
targets TEXT NOT NULL DEFAULT '[]',
complexity_threshold INTEGER,
heuristic_rules TEXT,
logic_level INTEGER,
primary_use TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
)`,
@@ -162,6 +164,10 @@ func (db *DB) RunMigrations() error {
}
}
// Add columns to existing model_groups tables (safe — SQLite ignores duplicates on error)
db.Exec("ALTER TABLE model_groups ADD COLUMN logic_level INTEGER")
db.Exec("ALTER TABLE model_groups ADD COLUMN primary_use TEXT")
// Default admin user
var count int
if err := db.Get(&count, "SELECT COUNT(*) FROM users"); err != nil {
@@ -190,14 +196,19 @@ func (db *DB) RunMigrations() error {
// Seed default model groups
defaultGroups := []struct {
id, strategy, targets string
logicLevel *int
primaryUse *string
}{
{"deepseek-auto", "heuristic", `["deepseek-chat","deepseek-reasoner"]`},
{"openai-auto", "heuristic", `["gpt-4o-mini","gpt-4o"]`},
{"gemini-auto", "heuristic", `["gemini-2.0-flash","gemini-2.5-pro"]`},
{"deepseek-auto", "heuristic", `["deepseek-chat","deepseek-reasoner"]`, nil, nil},
{"openai-auto", "heuristic", `["gpt-4o-mini","gpt-4o"]`, nil, nil},
{"gemini-auto", "heuristic", `["gemini-2.0-flash","gemini-2.5-pro"]`, nil, nil},
{"heavy-logic", "heuristic", `["grok-4.3","kimi-k2.5","deepseek-v4-pro"]`, intPtr(9), strPtr("Complex Coding, Logic, Agents.")},
{"standard-pro", "heuristic", `["gpt-5.4-mini","gemini-3-flash"]`, intPtr(5), strPtr("General Assistant, Long Docs.")},
{"fast-flow", "heuristic", `["deepseek-v4-flash","gpt-5.4-nano"]`, intPtr(2), strPtr("Classification, JSON, Basic Q&A.")},
}
for _, g := range defaultGroups {
db.Exec(`INSERT OR IGNORE INTO model_groups (id, strategy, targets) VALUES (?, ?, ?)`,
g.id, g.strategy, g.targets)
db.Exec(`INSERT OR IGNORE INTO model_groups (id, strategy, targets, logic_level, primary_use) VALUES (?, ?, ?, ?, ?)`,
g.id, g.strategy, g.targets, g.logicLevel, g.primaryUse)
}
return nil
@@ -293,6 +304,11 @@ type ModelGroup struct {
Targets string `db:"targets" json:"targets"` // JSON array
ComplexityThreshold *int `db:"complexity_threshold" json:"complexity_threshold"`
HeuristicRules *string `db:"heuristic_rules" json:"heuristic_rules"`
LogicLevel *int `db:"logic_level" json:"logic_level"`
PrimaryUse *string `db:"primary_use" json:"primary_use"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
func intPtr(v int) *int { return &v }
func strPtr(v string) *string { return &v }