(body: Record<string, unknown>)
| 180 | } |
| 181 | |
| 182 | function mockChatContent(body: Record<string, unknown>): string { |
| 183 | const prompt = getLastUserContent(body.messages).toLowerCase(); |
| 184 | const model = typeof body.model === "string" ? body.model : "unknown"; |
| 185 | |
| 186 | if (prompt.includes("2+2")) return "4"; |
| 187 | if (prompt.includes("7 times 8")) return "56"; |
| 188 | if (prompt.includes("capital of france")) return "Paris"; |
| 189 | if (prompt.includes("gravity")) return "Gravity is the attraction between masses."; |
| 190 | if (prompt.includes("count to")) return "1, 2, 3, 4, 5"; |
| 191 | if (prompt.includes("50-word story")) { |
| 192 | return [ |
| 193 | "A small cat named Mira guarded a sunlit bakery window.", |
| 194 | "Each morning she watched flour drift, bells ring, and neighbors wave.", |
| 195 | "When rain arrived, she curled beside the warm oven and purred so loudly", |
| 196 | "that every loaf seemed to rise a little higher.", |
| 197 | ].join(" "); |
| 198 | } |
| 199 | if (prompt.length > 100_000) return "Large payload accepted by mock upstream."; |
| 200 | if (prompt.includes("hello")) return "hello"; |
| 201 | return `mock response from ${model}`; |
| 202 | } |
| 203 | |
| 204 | async function startMockUpstream(): Promise<MockUpstream> { |
| 205 | const requests: MockRequest[] = []; |
no test coverage detected