MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / createAIChat

Method createAIChat

packages/node-runtime/src/ai/chats.ts:516–527  ·  view source on GitHub ↗
(sessionId: string, title: string | undefined, assistantId: string)

Source from the content-addressed store, hash-verified

514 // ==================== 对话管理 ====================
515
516 createAIChat(sessionId: string, title: string | undefined, assistantId: string): AIChat {
517 const db = this.getDb()
518 const now = Math.floor(Date.now() / 1000)
519 const id = this.generateId('conv')
520
521 db.prepare(
522 `INSERT INTO ai_chat (id, session_id, title, assistant_id, created_at, updated_at)
523 VALUES (?, ?, ?, ?, ?, ?)`
524 ).run(id, sessionId, title || null, assistantId, now, now)
525
526 return { id, sessionId, title: title || null, assistantId, activeMessageId: null, createdAt: now, updatedAt: now }
527 }
528
529 getAIChatCountsBySession(): Map<string, number> {
530 const result = new Map<string, number>()

Callers

nothing calls this directly

Calls 5

getDbMethod · 0.95
generateIdMethod · 0.95
runMethod · 0.65
prepareMethod · 0.65
nowMethod · 0.45

Tested by

no test coverage detected