Files

38 lines
1.4 KiB
SQL

-- name: InsertLLMModel :one
INSERT INTO llm_models (
id, endpoint_id, model_id, display_name, capabilities,
context_window, max_output_tokens,
prompt_price_per_million_usd, completion_price_per_million_usd, thinking_price_per_million_usd,
is_title_generator, enabled, sort_order
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13)
RETURNING *;
-- name: GetLLMModel :one
SELECT * FROM llm_models WHERE id = $1;
-- name: GetTitleGeneratorModel :one
SELECT * FROM llm_models WHERE is_title_generator = true AND enabled = true LIMIT 1;
-- name: ListLLMModels :many
SELECT * FROM llm_models
WHERE ($1::boolean = false) OR enabled = true
ORDER BY sort_order, display_name;
-- name: UpdateLLMModel :exec
UPDATE llm_models
SET display_name = COALESCE($2, display_name),
capabilities = COALESCE($3, capabilities),
context_window = COALESCE($4, context_window),
max_output_tokens = COALESCE($5, max_output_tokens),
prompt_price_per_million_usd = COALESCE($6, prompt_price_per_million_usd),
completion_price_per_million_usd = COALESCE($7, completion_price_per_million_usd),
thinking_price_per_million_usd = COALESCE($8, thinking_price_per_million_usd),
is_title_generator = COALESCE($9, is_title_generator),
enabled = COALESCE($10, enabled),
sort_order = COALESCE($11, sort_order),
updated_at = NOW()
WHERE id = $1;
-- name: DeleteLLMModel :exec
DELETE FROM llm_models WHERE id = $1;