(messages: ApiMessage[])
| 517 | * so the first message since the last summary is guaranteed to be a user message. |
| 518 | */ |
| 519 | export function getMessagesSinceLastSummary(messages: ApiMessage[]): ApiMessage[] { |
| 520 | const lastSummaryIndexReverse = [...messages].reverse().findIndex((message) => message.isSummary) |
| 521 | |
| 522 | if (lastSummaryIndexReverse === -1) { |
| 523 | return messages |
| 524 | } |
| 525 | |
| 526 | const lastSummaryIndex = messages.length - lastSummaryIndexReverse - 1 |
| 527 | return messages.slice(lastSummaryIndex) |
| 528 | } |
| 529 | |
| 530 | /** |
| 531 | * Filters the API conversation history to get the "effective" messages to send to the API. |
no outgoing calls
no test coverage detected