Skip to content

Commit

Permalink
quota test
Browse files Browse the repository at this point in the history
  • Loading branch information
nbonamy committed Oct 9, 2024
1 parent 3fff2fd commit 10bf76a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/mocks/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export default class LlmMock extends LlmEngine {
if (thread[thread.length-1].content.includes('no credit')) {
throw new LlmError('LowBalanceError', 400, 'Your balance is too low')
}
if (thread[thread.length-1].content.includes('quota')) {
throw new LlmError('QuotaExceededError', 429, 'You have exceeded your quota')
}

// model: switch to vision if needed
const model = this.selectModel(thread, opts?.model || this.getChatModel())
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/assistant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,9 @@ test('Low balance', async () => {
const content = assistant.chat.lastMessage().content
expect(content).toBe('Sorry, it seems you have run out of credits. Check the balance of your LLM provider account.')
})

test('Quota exceeded', async () => {
await prompt('quota exceeded')
const content = assistant.chat.lastMessage().content
expect(content).toBe('Sorry, it seems you have reached the rate limit of your LLM provider account. Try again later.')
})

0 comments on commit 10bf76a

Please sign in to comment.