(tokenCount: number)
| 242 | }); |
| 243 | |
| 244 | const createChatHistory = (tokenCount: number): ChatHistoryItem[] => { |
| 245 | // Create a message that will result in approximately the desired token count |
| 246 | const content = "x".repeat(tokenCount * 4); // 4 chars per token |
| 247 | return [ |
| 248 | { |
| 249 | message: { role: "user", content }, |
| 250 | contextItems: [], |
| 251 | }, |
| 252 | ]; |
| 253 | }; |
| 254 | |
| 255 | // Helper to calculate threshold using the new formula |
| 256 | const calculateThreshold = ( |