Skip to content

Commit b8679c0

Browse files
committed
change to "response_fields"
1 parent 4cf1fef commit b8679c0

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

examples/server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ These words will not be included in the completion, so make sure to add them to
450450

451451
`post_sampling_probs`: Returns the probabilities of top `n_probs` tokens after applying sampling chain.
452452

453-
`requested_fields`: A list of response fields, for example: `"requested_fields": ["content", "generation_settings/n_predict"]`. If the specified field is missing, it will simply be omitted from the response without triggering an error.
453+
`response_fields`: A list of response fields, for example: `"response_fields": ["content", "generation_settings/n_predict"]`. If the specified field is missing, it will simply be omitted from the response without triggering an error.
454454

455455
**Response format**
456456

examples/server/server.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct slot_params {
9292
int64_t t_max_predict_ms = -1; // if positive, limit the generation phase to this time limit
9393

9494
std::vector<std::string> antiprompt;
95-
std::vector<std::string> requested_fields;
95+
std::vector<std::string> response_fields;
9696
bool timings_per_token = false;
9797
bool post_sampling_probs = false;
9898
bool ignore_eos = false;
@@ -210,7 +210,7 @@ struct server_task {
210210
params.n_discard = json_value(data, "n_discard", defaults.n_discard);
211211
//params.t_max_prompt_ms = json_value(data, "t_max_prompt_ms", defaults.t_max_prompt_ms); // TODO: implement
212212
params.t_max_predict_ms = json_value(data, "t_max_predict_ms", defaults.t_max_predict_ms);
213-
params.requested_fields = json_value(data, "requested_fields", std::vector<std::string>());
213+
params.response_fields = json_value(data, "response_fields", std::vector<std::string>());
214214

215215
params.sampling.top_k = json_value(data, "top_k", defaults.sampling.top_k);
216216
params.sampling.top_p = json_value(data, "top_p", defaults.sampling.top_p);
@@ -524,7 +524,7 @@ struct server_task_result_cmpl_final : server_task_result {
524524

525525
bool post_sampling_probs;
526526
std::vector<completion_token_output> probs_output;
527-
std::vector<std::string> requested_fields;
527+
std::vector<std::string> response_fields;
528528

529529
slot_params generation_params;
530530

@@ -571,7 +571,7 @@ struct server_task_result_cmpl_final : server_task_result {
571571
if (!stream && !probs_output.empty()) {
572572
res["completion_probabilities"] = completion_token_output::probs_vector_to_json(probs_output, post_sampling_probs);
573573
}
574-
return requested_fields.empty() ? res : json_get_nested_values(requested_fields, res);
574+
return response_fields.empty() ? res : json_get_nested_values(response_fields, res);
575575
}
576576

577577
json to_json_oaicompat_chat() {
@@ -2066,7 +2066,7 @@ struct server_context {
20662066
res->tokens = slot.generated_tokens;
20672067
res->timings = slot.get_timings();
20682068
res->prompt = common_detokenize(ctx, slot.prompt_tokens, true);
2069-
res->requested_fields = slot.params.requested_fields;
2069+
res->response_fields = slot.params.response_fields;
20702070

20712071
res->truncated = slot.truncated;
20722072
res->n_decoded = slot.n_decoded;

examples/server/tests/unit/test_completion.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,14 @@ def check_slots_status():
258258

259259

260260
@pytest.mark.parametrize(
261-
"prompt,n_predict,requested_fields",
261+
"prompt,n_predict,response_fields",
262262
[
263263
("I believe the meaning of life is", 8, []),
264264
("I believe the meaning of life is", 32, ["content", "generation_settings/n_predict", "prompt"]),
265265
],
266266
)
267-
def test_completion_requested_fields(
268-
prompt: str, n_predict: int, requested_fields: list[str]
267+
def test_completion_response_fields(
268+
prompt: str, n_predict: int, response_fields: list[str]
269269
):
270270
global server
271271
server.start()
@@ -275,17 +275,17 @@ def test_completion_requested_fields(
275275
data={
276276
"n_predict": n_predict,
277277
"prompt": prompt,
278-
"requested_fields": requested_fields,
278+
"response_fields": response_fields,
279279
},
280280
)
281281
assert res.status_code == 200
282282
assert "content" in res.body
283283
assert len(res.body["content"])
284-
if len(requested_fields):
284+
if len(response_fields):
285285
assert res.body["generation_settings/n_predict"] == n_predict
286286
assert res.body["prompt"] == "<s> " + prompt
287287
assert isinstance(res.body["content"], str)
288-
assert len(res.body) == len(requested_fields)
288+
assert len(res.body) == len(response_fields)
289289
else:
290290
assert len(res.body)
291291
assert "generation_settings" in res.body

0 commit comments

Comments
 (0)