Skip to content

Commit ade213b

Browse files
authored
fix: return proper error message when the model is not found (#1331)
* fix: return proper error message when the model is not found * use global source for the domain Co-authored-by: Eric Dubé <[email protected]> --------- Co-authored-by: Eric Dubé <[email protected]> Closes #1326
1 parent c7970fd commit ade213b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/backend/src/modules/puterai/AIChatService.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,17 @@ class AIChatService extends BaseService {
437437
const model_details = this.get_model_details(model_used, {
438438
service_used,
439439
});
440+
441+
if ( ! model_details ) {
442+
// TODO (xiaochen): replace with a standard link
443+
const available_models_url = this.global_config.origin + "/puterai/chat/models";
444+
445+
throw APIError.create('field_invalid', null, {
446+
key: 'model',
447+
expected: `a valid model name from ${available_models_url}`,
448+
got: model_used,
449+
});
450+
}
440451

441452
const model_input_cost = model_details.cost.input;
442453
const model_output_cost = model_details.cost.output;

0 commit comments

Comments
 (0)