Skip to content

Commit 936c79b

Browse files
server : relay error messages (#4131)
1 parent 262005a commit 936c79b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

examples/server/public/completion.js

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ export async function* llama(prompt, params = {}, config = {}) {
9494
break;
9595
}
9696
}
97+
if (result.error) {
98+
result.error = JSON.parse(result.error);
99+
console.error(`llama.cpp error: ${result.error.content}`);
100+
}
97101
}
98102
}
99103
}

examples/server/server.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,17 @@ int main(int argc, char **argv)
23682368
break;
23692369
}
23702370
} else {
2371+
const std::string str =
2372+
"error: " +
2373+
result.result_json.dump(-1, ' ', false, json::error_handler_t::replace) +
2374+
"\n\n";
2375+
LOG_VERBOSE("data stream", {
2376+
{ "to_send", str }
2377+
});
2378+
if (!sink.write(str.c_str(), str.size()))
2379+
{
2380+
return false;
2381+
}
23712382
break;
23722383
}
23732384
}

0 commit comments

Comments
 (0)