INSERT INTO `la_ai_config` (`name`, `value`, `remark`, `create_time`, `update_time`)
SELECT 'openai_api_key', '', 'OpenAI Responses API Key（建议通过 server/.env 的 OPENAI_API_KEY 配置）', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
WHERE NOT EXISTS (SELECT 1 FROM `la_ai_config` WHERE `name` = 'openai_api_key');

INSERT INTO `la_ai_config` (`name`, `value`, `remark`, `create_time`, `update_time`)
SELECT 'openai_base_url', 'https://lingsuan.top', 'OpenAI Responses Base URL（不带 /v1）', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
WHERE NOT EXISTS (SELECT 1 FROM `la_ai_config` WHERE `name` = 'openai_base_url');

UPDATE `la_ai_config`
SET `value` = 'https://lingsuan.top', `update_time` = UNIX_TIMESTAMP()
WHERE `name` = 'openai_base_url';

INSERT INTO `la_ai_config` (`name`, `value`, `remark`, `create_time`, `update_time`)
SELECT 'openai_model', 'gpt-5.5', 'OpenAI 默认生成模型', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
WHERE NOT EXISTS (SELECT 1 FROM `la_ai_config` WHERE `name` = 'openai_model');

UPDATE `la_ai_config`
SET `value` = 'gpt-5.5', `update_time` = UNIX_TIMESTAMP()
WHERE `name` = 'openai_model';

INSERT INTO `la_ai_config` (`name`, `value`, `remark`, `create_time`, `update_time`)
SELECT 'openai_wire_api', 'responses', 'OpenAI 调用协议：responses/chat', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
WHERE NOT EXISTS (SELECT 1 FROM `la_ai_config` WHERE `name` = 'openai_wire_api');

UPDATE `la_ai_config`
SET `value` = 'responses', `update_time` = UNIX_TIMESTAMP()
WHERE `name` = 'openai_wire_api';

INSERT INTO `la_ai_config` (`name`, `value`, `remark`, `create_time`, `update_time`)
SELECT 'openai_provider_label', 'OpenAI', 'AI 日志/错误提示中的提供商名称', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
WHERE NOT EXISTS (SELECT 1 FROM `la_ai_config` WHERE `name` = 'openai_provider_label');

UPDATE `la_ai_config`
SET `value` = 'OpenAI', `update_time` = UNIX_TIMESTAMP()
WHERE `name` = 'openai_provider_label';

INSERT INTO `la_ai_config` (`name`, `value`, `remark`, `create_time`, `update_time`)
SELECT 'openai_reasoning_effort', 'xhigh', 'OpenAI Responses reasoning effort', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
WHERE NOT EXISTS (SELECT 1 FROM `la_ai_config` WHERE `name` = 'openai_reasoning_effort');

UPDATE `la_ai_config`
SET `value` = 'xhigh', `update_time` = UNIX_TIMESTAMP()
WHERE `name` = 'openai_reasoning_effort';

INSERT INTO `la_ai_config` (`name`, `value`, `remark`, `create_time`, `update_time`)
SELECT 'openai_disable_response_storage', '1', 'OpenAI Responses 是否关闭存储：1关闭0开启', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
WHERE NOT EXISTS (SELECT 1 FROM `la_ai_config` WHERE `name` = 'openai_disable_response_storage');

UPDATE `la_ai_config`
SET `value` = '1', `update_time` = UNIX_TIMESTAMP()
WHERE `name` = 'openai_disable_response_storage';
