(input: AskInput)
| 179 | * let a slow index turn into a difference between two models' scores. |
| 180 | */ |
| 181 | export async function compileQuestion(input: AskInput): Promise<CompiledQuestion> { |
| 182 | const depth = input.depth ?? NEIGHBOR_DEPTH_DEFAULT; |
| 183 | const packet = await compileFacts(input.source, input.root, input.question, { |
| 184 | depth, |
| 185 | ...(input.context === undefined ? {} : { context: input.context }), |
| 186 | ...(input.focus === undefined ? {} : { focus: input.focus }), |
| 187 | ...(input.chosenSubject === undefined ? {} : { chosenSubject: input.chosenSubject }), |
| 188 | ...(input.observed === undefined ? {} : { observed: input.observed }), |
| 189 | ...(input.opts ?? {}), |
| 190 | }); |
| 191 | const cards = compileCards(packet, { budget: cardBudgetOf(input.modelClass) }); |
| 192 | if (cards.cards.length === 0) { |
| 193 | return { packet, cards }; |
| 194 | } |
| 195 | return { |
| 196 | packet, |
| 197 | cards, |
| 198 | plan: buildPrompt({ |
| 199 | question: input.question, |
| 200 | klass: packet.klass, |
| 201 | cards, |
| 202 | modelName: input.modelName, |
| 203 | }), |
| 204 | }; |
| 205 | } |
| 206 | |
| 207 | /** Tokens per second, or nothing when the sidecar did not report enough to say. */ |
| 208 | export function tokensPerSecond(completionTokens: number | undefined, durationMs: number): number | undefined { |
no test coverage detected