]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server : throw an error when `slot unavailable` (#4741)
authorJustin Parker <redacted>
Wed, 3 Jan 2024 08:43:19 +0000 (03:43 -0500)
committerGitHub <redacted>
Wed, 3 Jan 2024 08:43:19 +0000 (10:43 +0200)
examples/server/public/completion.js

index 6e2b99565dc6e48abee02556e3231cfab1488712..baaec1d6076fb638fda279282bc31c3acaba0542 100644 (file)
@@ -95,6 +95,15 @@ export async function* llama(prompt, params = {}, config = {}) {
               break;
             }
           }
+          if (result.error) {
+            result.error = JSON.parse(result.error);
+            if (result.error.content.includes('slot unavailable')) {
+              // Throw an error to be caught by upstream callers
+              throw new Error('slot unavailable');
+            } else {
+              console.error(`llama.cpp error: ${result.error.content}`);
+            }
+          }
           if (result.error) {
             result.error = JSON.parse(result.error);
             console.error(`llama.cpp error: ${result.error.content}`);