feat: provider api_formats 可空继承、OpenAI 图片 edit/variation 与用量配额多项补强

- 鉴权: provider_api_keys.api_formats 改为可空,OAuth 托管 key 自动继承 provider endpoints 激活格式,相关 handler/测试同步更新
- 图片 planner: OpenAI 图片路由新增 edit/variation 操作并完善参数校验、响应合并与流式处理
- 用量: user me usage 返回区分 client_requested_stream/upstream_is_stream,前端 usage 列表筛选与展示增强
- 统计: stats_daily_model 新增 cache_creation_ephemeral_5m/1h tokens 字段与回填链路
- 配额/observability: quota repository 新增内存与 SQL 扩展,admin observability usage 字段扩充
- 其它: OAuth 导入/轮询收敛、provider 汇总与 pool admin 读写链路小修、新增 system_config 缓存与 provider template handler

Closes #318

Co-authored-by: Entropy.Xu <53283266+Entropy-Xu@users.noreply.github.com>
This commit is contained in:
fawney19
2026-04-23 14:42:51 +08:00
parent f55f22d2e8
commit fa328e18a1
128 changed files with 5583 additions and 690 deletions

View File

@@ -494,7 +494,7 @@ CREATE TABLE IF NOT EXISTS public.provider_api_keys (
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
provider_id character varying(36) NOT NULL,
api_formats json DEFAULT '[]'::json NOT NULL,
api_formats json,
rate_multipliers json,
health_by_format jsonb,
circuit_breaker_by_format jsonb,

View File

@@ -0,0 +1,34 @@
ALTER TABLE public.provider_api_keys
ALTER COLUMN api_formats DROP DEFAULT,
ALTER COLUMN api_formats DROP NOT NULL;
UPDATE public.provider_api_keys AS pak
SET
api_formats = NULL,
updated_at = NOW()
FROM public.providers AS p
WHERE p.id = pak.provider_id
AND pak.api_formats IS NOT NULL
AND pak.api_formats::jsonb = '[]'::jsonb
AND (
(
LOWER(BTRIM(p.provider_type)) IN (
'claude_code',
'codex',
'gemini_cli',
'vertex_ai',
'antigravity'
)
AND LOWER(BTRIM(pak.auth_type)) = 'oauth'
)
OR (
LOWER(BTRIM(p.provider_type)) = 'kiro'
AND (
LOWER(BTRIM(pak.auth_type)) = 'oauth'
OR (
LOWER(BTRIM(pak.auth_type)) = 'bearer'
AND COALESCE(BTRIM(pak.auth_config), '') <> ''
)
)
)
);

View File

@@ -0,0 +1,3 @@
ALTER TABLE public.stats_daily_model
ADD COLUMN IF NOT EXISTS cache_creation_ephemeral_5m_tokens bigint DEFAULT '0'::bigint NOT NULL,
ADD COLUMN IF NOT EXISTS cache_creation_ephemeral_1h_tokens bigint DEFAULT '0'::bigint NOT NULL;