Spaces:
Sleeping
Sleeping
File size: 769 Bytes
23d418f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // What the chat sends with a follow-up: the earlier turns that got an answer, each with
// the question as the system understood it (a rewritten follow-up, not the raw words),
// so the next rewrite builds on resolved questions. The server reads only the last few
// (config.WEB_HISTORY_TURNS = 4); sending just those keeps the request small.
import type { RunState } from './run'
import type { HistoryTurn } from './sse'
export const HISTORY_TURNS = 4 // mirrors config.WEB_HISTORY_TURNS
export function historyOf(turns: { question: string; run: RunState }[]): HistoryTurn[] {
return turns
.filter((t) => t.run.answer !== null)
.slice(-HISTORY_TURNS)
.map((t) => ({ question: t.run.rewrite?.question ?? t.question, answer: t.run.answer!.answer }))
}
|