(chatKey: string, tag: string, q: string, a: string)
| 334 | } |
| 335 | |
| 336 | async appendTurn(chatKey: string, tag: string, q: string, a: string): Promise<void> { |
| 337 | this.ensureReady(); |
| 338 | const ctx = await this.ensureCtxChat(chatKey); |
| 339 | ctx.contextTurns ||= {}; |
| 340 | const turns = ctx.contextTurns[tag] || []; |
| 341 | turns.push({ q, a, at: new Date().toISOString() }); |
| 342 | ctx.contextTurns[tag] = turns.slice(-MAX_TURNS_PER_TAG); |
| 343 | |
| 344 | const key = this.gk(chatKey); |
| 345 | this.dbCtx.data!.chats[key] = ctx; |
| 346 | await this.dbCtx.write(); |
| 347 | } |
| 348 | |
| 349 | async getTurns(chatKey: string, tag: string): Promise<ContextTurn[]> { |
| 350 | this.ensureReady(); |
no test coverage detected