Files
libredesk/internal/ai/queries.sql
Abhinav Raut 26d76c966f feat: allow setting OpenAI API KEY from the UI.
feat: new `ai:manage` permission for the same
Migrations for new role.
2025-03-01 19:40:18 +05:30

18 lines
456 B
SQL

-- name: get-default-provider
SELECT id, name, provider, config, is_default FROM ai_providers where is_default is true;
-- name: get-prompt
SELECT id, key, title, content FROM ai_prompts where key = $1;
-- name: get-prompts
SELECT id, key, title FROM ai_prompts order by title;
-- name: set-openai-key
UPDATE ai_providers
SET config = jsonb_set(
COALESCE(config, '{}'::jsonb),
'{api_key}',
to_jsonb($1::text)
)
WHERE provider = 'openai';