feat(数据库): 添加 AI 生成图片字段支持

- messages 表新增 generated_images 字段存储 Gemini 生成的图片
- 定义 GeneratedImageData 接口(mimeType, data, width, height)
- shared_conversations 表新增 selected_message_ids 字段
This commit is contained in:
gaoziman 2025-12-27 15:01:42 +08:00
parent 4efee3a06a
commit 4c43fb4471
4 changed files with 1360 additions and 0 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE "messages" ADD COLUMN "generated_images" jsonb;--> statement-breakpoint
ALTER TABLE "shared_conversations" ADD COLUMN "selected_message_ids" jsonb;

File diff suppressed because it is too large Load Diff

View File

@ -106,6 +106,13 @@
"when": 1766546111189, "when": 1766546111189,
"tag": "0014_naive_kronos", "tag": "0014_naive_kronos",
"breakpoints": true "breakpoints": true
},
{
"idx": 15,
"version": "7",
"when": 1766812096044,
"tag": "0015_milky_anthem",
"breakpoints": true
} }
] ]
} }

View File

@ -207,6 +207,8 @@ export const messages = pgTable('messages', {
usedTools: jsonb('used_tools').$type<string[]>().default([]), usedTools: jsonb('used_tools').$type<string[]>().default([]),
// 搜索到的图片(图片搜索工具返回) // 搜索到的图片(图片搜索工具返回)
searchImages: jsonb('search_images').$type<SearchImageData[]>(), searchImages: jsonb('search_images').$type<SearchImageData[]>(),
// AI 生成的图片Gemini 等图片生成模型返回)
generatedImages: jsonb('generated_images').$type<GeneratedImageData[]>(),
// Token 统计 // Token 统计
inputTokens: integer('input_tokens').default(0), inputTokens: integer('input_tokens').default(0),
outputTokens: integer('output_tokens').default(0), outputTokens: integer('output_tokens').default(0),
@ -479,6 +481,14 @@ export interface SearchImageData {
sourceUrl?: string; sourceUrl?: string;
} }
// AI 生成的图片数据(用于 Gemini 等图片生成模型)
export interface GeneratedImageData {
mimeType: string; // 图片 MIME 类型,如 "image/png"、"image/jpeg"
data: string; // Base64 编码的图片数据
width?: number; // 图片宽度(可选)
height?: number; // 图片高度(可选)
}
// 导出类型 // 导出类型
export type User = typeof users.$inferSelect; export type User = typeof users.$inferSelect;
export type NewUser = typeof users.$inferInsert; export type NewUser = typeof users.$inferInsert;