Skip to content

Commit

Permalink
assistant test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nbonamy committed May 2, 2024
1 parent a14bca2 commit e88e26f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/build_number.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
166
167
3 changes: 0 additions & 3 deletions src/services/assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,10 @@ export default class {
if (error.name !== 'AbortError') {
if (error.status === 401 || error.message.includes('401') || error.message.toLowerCase().includes('apikey')) {
message.setText('You need to enter your API key in the Models tab of <a href="#settings">Settings</a> in order to chat.')
callback?.call(null, { done: true })
} else if (error.status === 400 && (error.message.includes('credit') || error.message.includes('balance'))) {
message.setText('Sorry, it seems you have run out of credits. Check the balance of your LLM provider account.')
callback?.call(null, { done: true })
} else if (message.content === '') {
message.setText('Sorry, I could not generate text for that prompt.')
callback?.call(null, { done: true })
} else {
message.appendText({ text: '\n\nSorry, I am not able to continue here.', done: true })
}
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/assistant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ let assistant: Assistant = null
const prompt = async (prompt: string, opts: LlmCompletionOpts = {}): Promise<string> => {

// callback
let done = false
let content = ''
const callback = (chunk: LlmStream) => {
done = chunk?.done
content += chunk?.text || ''
}

// call and wait
await assistant.prompt(prompt, { ...opts, save: false }, callback)
await vi.waitUntil(async () => done)
await vi.waitUntil(async () => !assistant.chat.lastMessage().transient)

// return
return content
Expand Down

0 comments on commit e88e26f

Please sign in to comment.