feat: add clear error message when llama-server not running
This commit is contained in:
@@ -48,14 +48,22 @@ export class LlamaCppClient implements ModelClient {
|
||||
headers['Authorization'] = `Bearer ${this.authToken}`;
|
||||
}
|
||||
|
||||
const response = await fetch(`${this.endpoint}/v1/chat/completions`, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
messages,
|
||||
max_tokens: request.maxTokens ?? 2048,
|
||||
}),
|
||||
});
|
||||
let response: Response;
|
||||
try {
|
||||
response = await fetch(`${this.endpoint}/v1/chat/completions`, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
messages,
|
||||
max_tokens: request.maxTokens ?? 2048,
|
||||
}),
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof TypeError && error.message.includes('fetch failed')) {
|
||||
throw new Error(`llama-server not running at ${this.endpoint}`);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const text = await response.text();
|
||||
|
||||
Reference in New Issue
Block a user