Skip to content

Commit f2eb19b

Browse files
authored
server : throw an error when slot unavailable (#4741)
1 parent f3f62f0 commit f2eb19b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

examples/server/public/completion.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ export async function* llama(prompt, params = {}, config = {}) {
9595
break;
9696
}
9797
}
98+
if (result.error) {
99+
result.error = JSON.parse(result.error);
100+
if (result.error.content.includes('slot unavailable')) {
101+
// Throw an error to be caught by upstream callers
102+
throw new Error('slot unavailable');
103+
} else {
104+
console.error(`llama.cpp error: ${result.error.content}`);
105+
}
106+
}
98107
if (result.error) {
99108
result.error = JSON.parse(result.error);
100109
console.error(`llama.cpp error: ${result.error.content}`);

0 commit comments

Comments
 (0)