Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tools/server/server-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ json format_error_response(const std::string & message, const enum error_type ty
type_str = "exceed_context_size_error";
code = 400;
break;
case ERROR_TYPE_INVALID_PROMPT:
type_str = "invalid_prompt";
code = 400;
break;
}
return json {
{"code", code},
Expand Down
1 change: 1 addition & 0 deletions tools/server/server-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum error_type {
ERROR_TYPE_UNAVAILABLE, // custom error
ERROR_TYPE_NOT_SUPPORTED, // custom error
ERROR_TYPE_EXCEED_CONTEXT_SIZE, // custom error
ERROR_TYPE_INVALID_PROMPT, // custom error - for bad token IDs in prompt array
};

// thin wrapper around common_grammar_trigger with (de)serialization functions
Expand Down
4 changes: 2 additions & 2 deletions tools/server/server-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ struct server_context_impl {
}

if (!task.tokens.validate(ctx_tgt)) {
send_error(task, "Prompt contains invalid tokens", ERROR_TYPE_INVALID_REQUEST);
send_error(task, "Prompt contains invalid tokens", ERROR_TYPE_INVALID_PROMPT);
return false;
}

Expand Down Expand Up @@ -2172,7 +2172,7 @@ struct server_context_impl {
task.cli_prompt.clear();
task.cli_files.clear();
} catch (const std::exception & e) {
send_error(task, std::string("Failed to format input: ") + e.what(), ERROR_TYPE_INVALID_REQUEST);
send_error(task, std::string("Failed to format input: ") + e.what(), ERROR_TYPE_INVALID_PROMPT);
return false;
}
return true;
Expand Down