feat: add model_groups table and default seed data
This commit is contained in:
@@ -122,6 +122,16 @@ func (db *DB) RunMigrations() error {
|
|||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
last_used_at DATETIME,
|
last_used_at DATETIME,
|
||||||
FOREIGN KEY (client_id) REFERENCES clients(client_id) ON DELETE CASCADE
|
FOREIGN KEY (client_id) REFERENCES clients(client_id) ON DELETE CASCADE
|
||||||
|
)`,
|
||||||
|
`CREATE TABLE IF NOT EXISTS model_groups (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
strategy TEXT NOT NULL DEFAULT 'heuristic',
|
||||||
|
selector_model TEXT,
|
||||||
|
targets TEXT NOT NULL DEFAULT '[]',
|
||||||
|
complexity_threshold INTEGER,
|
||||||
|
heuristic_rules TEXT,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
)`,
|
)`,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,6 +187,19 @@ func (db *DB) RunMigrations() error {
|
|||||||
return fmt.Errorf("failed to insert default client: %w", err)
|
return fmt.Errorf("failed to insert default client: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Seed default model groups
|
||||||
|
defaultGroups := []struct {
|
||||||
|
id, strategy, targets 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"]`},
|
||||||
|
}
|
||||||
|
for _, g := range defaultGroups {
|
||||||
|
db.Exec(`INSERT OR IGNORE INTO model_groups (id, strategy, targets) VALUES (?, ?, ?)`,
|
||||||
|
g.id, g.strategy, g.targets)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,3 +285,14 @@ type ClientToken struct {
|
|||||||
CreatedAt time.Time `db:"created_at"`
|
CreatedAt time.Time `db:"created_at"`
|
||||||
LastUsedAt *time.Time `db:"last_used_at"`
|
LastUsedAt *time.Time `db:"last_used_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ModelGroup struct {
|
||||||
|
ID string `db:"id" json:"id"`
|
||||||
|
Strategy string `db:"strategy" json:"strategy"`
|
||||||
|
SelectorModel *string `db:"selector_model" json:"selector_model"`
|
||||||
|
Targets string `db:"targets" json:"targets"` // JSON array
|
||||||
|
ComplexityThreshold *int `db:"complexity_threshold" json:"complexity_threshold"`
|
||||||
|
HeuristicRules *string `db:"heuristic_rules" json:"heuristic_rules"`
|
||||||
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user