feat: 新增模型管理功能(供应商 + 模型 CRUD)
- 新增 providers/models 数据库表、迁移和数据访问层 - 新增 15 个后端 API 路由(供应商/模型 CRUD + 连通性测试) - 新增 AI 服务层(registry.ts: buildProviderRegistry + testProviderConnection) - 新增前端模型管理页面(Tabs: 供应商/模型,含表格、表单、工具栏) - 新增前端 hooks(use-providers, use-models) - 新增共享类型和 MODEL_CAPABILITIES 常量 - 新增 10 个测试文件(66 个测试用例,4 个因 bun test ESM 兼容问题待修复) - 更新开发文档(architecture, backend, frontend) - 附带 apply-review 修复:统一错误响应、提取共享常量、清理重复测试 注意:registry.test.ts 中 4 个测试因 bun test 无法解析 createProviderRegistry ESM 导出而失败,详情见 context.md
This commit is contained in:
@@ -3,11 +3,32 @@ export interface ApiErrorResponse {
|
||||
status: number;
|
||||
}
|
||||
|
||||
export interface CreateModelRequest {
|
||||
capabilities: ModelCapability[];
|
||||
contextLength?: null | number;
|
||||
maxOutputTokens?: null | number;
|
||||
modelId: string;
|
||||
name: string;
|
||||
providerId: string;
|
||||
}
|
||||
|
||||
export interface CreateProjectRequest {
|
||||
description?: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 在此定义你的业务类型
|
||||
// 前后端共享的类型都放在这个文件中
|
||||
// ==========================================
|
||||
|
||||
export interface CreateProviderRequest {
|
||||
apiKey: string;
|
||||
baseUrl: string;
|
||||
name: string;
|
||||
type: ProviderType;
|
||||
}
|
||||
|
||||
export interface MetaResponse {
|
||||
ok: true;
|
||||
service: string;
|
||||
@@ -15,10 +36,50 @@ export interface MetaResponse {
|
||||
version: string;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 在此定义你的业务类型
|
||||
// 前后端共享的类型都放在这个文件中
|
||||
// ==========================================
|
||||
export interface Model {
|
||||
capabilities: ModelCapability[];
|
||||
contextLength: null | number;
|
||||
createdAt: string;
|
||||
enabled: boolean;
|
||||
id: string;
|
||||
maxOutputTokens: null | number;
|
||||
modelId: string;
|
||||
name: string;
|
||||
providerId: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type ModelCapability =
|
||||
| "audio-generation"
|
||||
| "audio-recognition"
|
||||
| "image-generation"
|
||||
| "image-recognition"
|
||||
| "reasoning"
|
||||
| "text"
|
||||
| "video-generation"
|
||||
| "video-recognition";
|
||||
|
||||
export const MODEL_CAPABILITIES: readonly ModelCapability[] = [
|
||||
"audio-generation",
|
||||
"audio-recognition",
|
||||
"image-generation",
|
||||
"image-recognition",
|
||||
"reasoning",
|
||||
"text",
|
||||
"video-generation",
|
||||
"video-recognition",
|
||||
];
|
||||
|
||||
export interface ModelListResponse {
|
||||
items: Model[];
|
||||
page: number;
|
||||
pageSize: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface ModelResponse {
|
||||
model: Model;
|
||||
}
|
||||
|
||||
export interface Project {
|
||||
archivedAt: null | string;
|
||||
@@ -43,9 +104,54 @@ export interface ProjectResponse {
|
||||
|
||||
export type ProjectStatus = "active" | "archived";
|
||||
|
||||
export interface Provider {
|
||||
apiKey: string;
|
||||
baseUrl: string;
|
||||
createdAt: string;
|
||||
enabled: boolean;
|
||||
id: string;
|
||||
name: string;
|
||||
type: ProviderType;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ProviderListResponse {
|
||||
items: Provider[];
|
||||
page: number;
|
||||
pageSize: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface ProviderResponse {
|
||||
provider: Provider;
|
||||
}
|
||||
|
||||
export interface ProviderTestResponse {
|
||||
message: string;
|
||||
ok: boolean;
|
||||
}
|
||||
|
||||
export type ProviderType = "anthropic" | "openai" | "openai-compatible";
|
||||
|
||||
export type RuntimeMode = "development" | "production" | "test";
|
||||
|
||||
export interface UpdateModelRequest {
|
||||
capabilities?: ModelCapability[];
|
||||
contextLength?: null | number;
|
||||
maxOutputTokens?: null | number;
|
||||
modelId?: string;
|
||||
name?: string;
|
||||
providerId?: string;
|
||||
}
|
||||
|
||||
export interface UpdateProjectRequest {
|
||||
description?: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface UpdateProviderRequest {
|
||||
apiKey?: string;
|
||||
baseUrl?: string;
|
||||
name?: string;
|
||||
type?: ProviderType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user