feat: configure deep search llm models

This commit is contained in:
john
2026-07-23 22:46:10 +08:00
parent be1e4c18c0
commit 784a10a592
11 changed files with 360 additions and 35 deletions
+31 -4
View File
@@ -29,6 +29,8 @@ function mapTask(row) {
userId: row.user_id || null,
question: row.question,
depth: row.depth,
llmProviderKeyId: row.llm_provider_key_id || '',
llmModel: row.llm_model || '',
status: row.status,
progress: row.progress,
phase: row.phase,
@@ -72,6 +74,8 @@ export function createDeepSearchStore({
user_id TEXT,
question TEXT NOT NULL,
depth TEXT NOT NULL,
llm_provider_key_id TEXT NOT NULL DEFAULT '',
llm_model TEXT NOT NULL DEFAULT '',
status TEXT NOT NULL,
progress INTEGER NOT NULL DEFAULT 0,
phase TEXT NOT NULL DEFAULT 'queued',
@@ -114,11 +118,18 @@ export function createDeepSearchStore({
CREATE INDEX IF NOT EXISTS idx_research_sources_task ON research_sources(task_id, score DESC);
CREATE INDEX IF NOT EXISTS idx_research_events_task ON research_events(task_id, seq);
`);
const taskColumns = new Set(db.prepare('PRAGMA table_info(research_tasks)').all().map((row) => row.name));
if (!taskColumns.has('llm_provider_key_id')) {
db.exec("ALTER TABLE research_tasks ADD COLUMN llm_provider_key_id TEXT NOT NULL DEFAULT ''");
}
if (!taskColumns.has('llm_model')) {
db.exec("ALTER TABLE research_tasks ADD COLUMN llm_model TEXT NOT NULL DEFAULT ''");
}
const createTaskStmt = db.prepare(`
INSERT INTO research_tasks
(id, user_id, question, depth, status, progress, phase, created_at, updated_at)
VALUES (?, ?, ?, ?, 'queued', 0, 'queued', ?, ?)
(id, user_id, question, depth, llm_provider_key_id, llm_model, status, progress, phase, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, 'queued', 0, 'queued', ?, ?)
`);
const getTaskStmt = db.prepare('SELECT * FROM research_tasks WHERE id = ?');
const listTasksStmt = db.prepare('SELECT * FROM research_tasks ORDER BY created_at DESC LIMIT ?');
@@ -165,9 +176,25 @@ export function createDeepSearchStore({
}
return {
createTask({ id, userId = null, question, depth }) {
createTask({
id,
userId = null,
question,
depth,
llmProviderKeyId = '',
llmModel = '',
}) {
const timestamp = now();
createTaskStmt.run(id, userId, question, depth, timestamp, timestamp);
createTaskStmt.run(
id,
userId,
question,
depth,
llmProviderKeyId,
llmModel,
timestamp,
timestamp,
);
appendEventStmt.run(id, 'queued', JSON.stringify({ depth }), timestamp);
return getTask(id);
},