返回 oh-my-ppt
add-model-max-tokens.ts
根目录 / src / main / db / patch / add-model-max-tokens.ts
1 import type { createClient } from '@libsql/client'
2
3 type LibSqlClient = ReturnType<typeof createClient>
4
5 /**
6 * Patch: add max_tokens column to model_configs table.
7 * Default 4096 (safe for GLM series, reasonable for most models).
8 */
9 export const patchModelConfigMaxTokens = async (client: LibSqlClient): Promise<void> => {
10 // Check if column already exists
11 const cols = await client.execute("PRAGMA table_info('model_configs')")
12 const hasMaxTokens = cols.rows.some((r) => r.name === 'max_tokens')
13 if (hasMaxTokens) return
14
15 await client.execute(
16 "ALTER TABLE model_configs ADD COLUMN max_tokens INTEGER NOT NULL DEFAULT 4096"
17 )
18 }
19
19 lines TYPESCRIPT