Преглед изворни кода

server : throw an error when `slot unavailable` (#4741)

Justin Parker пре 2 година
родитељ
комит
f2eb19bd8b
1 измењених фајлова са 9 додато и 0 уклоњено
  1. 9 0
      examples/server/public/completion.js

+ 9 - 0
examples/server/public/completion.js

@@ -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}`);