AI 小说工坊:主编 + 作家多模型协作写作应用

- Nuxt 4 + Nuxt UI 4 + AI SDK 7 + Drizzle/SQLite
- 主编规划大纲与章节简报、选派作家;作家流式写入章节文件并实时推送前端
- 逐章确认模式(默认)与自动模式;摘要与故事记忆
- 酒馆角色卡(PNG/JSON,V1-V3)与世界书导入
- 自定义最高优先级系统提示词、审稿/修改/多版本、任务日志与提示词检视
- 模拟 LLM 服务与端到端测试脚本

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jocay
2026-10-18 02:04:40 +08:00
commit 3c9b65d982
106 changed files with 16286 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
import { eq } from 'drizzle-orm'
export default defineEventHandler((event) => {
useDb().delete(tables.providers).where(eq(tables.providers.id, param(event))).run()
return { ok: true }
})
+22
View File
@@ -0,0 +1,22 @@
import { eq } from 'drizzle-orm'
import { z } from 'zod'
const schema = z.object({
name: z.string().min(1).optional(),
type: z.enum(['openai-compatible', 'anthropic', 'google']).optional(),
baseUrl: z.string().optional(),
// 不传或传空字符串表示保留原有密钥
apiKey: z.string().optional()
})
export default defineEventHandler(async (event) => {
const id = param(event)
const body = await readJson(event, schema)
const patch: Partial<typeof tables.providers.$inferInsert> = {}
if (body.name !== undefined) patch.name = body.name
if (body.type !== undefined) patch.type = body.type
if (body.baseUrl !== undefined) patch.baseUrl = body.baseUrl.trim()
if (body.apiKey) patch.apiKeyEnc = encryptSecret(body.apiKey.trim())
useDb().update(tables.providers).set(patch).where(eq(tables.providers.id, id)).run()
return { ok: true }
})
@@ -0,0 +1,13 @@
import { eq } from 'drizzle-orm'
/** 拉取提供方的可用模型列表 */
export default defineEventHandler(async (event) => {
const p = useDb().select().from(tables.providers).where(eq(tables.providers.id, param(event))).get()
if (!p) throw createError({ statusCode: 404, message: '提供方不存在' })
try {
return await listRemoteModels(p.type, p.baseUrl, decryptSecret(p.apiKeyEnc))
}
catch (err) {
throw createError({ statusCode: 502, message: `获取模型列表失败:${describeError(err)}` })
}
})
+11
View File
@@ -0,0 +1,11 @@
import { asc } from 'drizzle-orm'
export default defineEventHandler(() => {
const rows = useDb().select().from(tables.providers).orderBy(asc(tables.providers.createdAt)).all()
return rows.map(({ apiKeyEnc, ...p }) => {
let masked = ''
try { masked = maskSecret(decryptSecret(apiKeyEnc)) }
catch { masked = '(无法解密,请重新填写)' }
return { ...p, apiKeyMasked: masked, hasKey: Boolean(apiKeyEnc) }
})
})
+20
View File
@@ -0,0 +1,20 @@
import { z } from 'zod'
const schema = z.object({
name: z.string().min(1),
type: z.enum(['openai-compatible', 'anthropic', 'google']),
baseUrl: z.string().default(''),
apiKey: z.string().default('')
})
export default defineEventHandler(async (event) => {
const body = await readJson(event, schema)
const row = useDb().insert(tables.providers).values({
id: newId(),
name: body.name,
type: body.type,
baseUrl: body.baseUrl.trim(),
apiKeyEnc: encryptSecret(body.apiKey.trim())
}).returning().get()
return { id: row.id }
})