From 42c44893a672a1a6a8ae69a9840ec7c1874d078a Mon Sep 17 00:00:00 2001 From: MichelleTPY Date: Fri, 13 Dec 2024 18:39:33 +0000 Subject: [PATCH 1/4] Update server JSON response. --- examples/server/server.cpp | 2 +- examples/server/utils.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index 8cb992470a302..accb1c722eeb8 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -459,7 +459,7 @@ struct server_task_result_cmpl_final : server_task_result { int32_t n_decoded; int32_t n_prompt_tokens; int32_t n_tokens_cached; - int32_t has_new_line; + bool has_new_line; std::string stopping_word; stop_type stop = STOP_TYPE_NONE; diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp index 2fcb895abe7e4..c6f08bf21071a 100644 --- a/examples/server/utils.hpp +++ b/examples/server/utils.hpp @@ -22,7 +22,7 @@ #include #include -#define DEFAULT_OAICOMPAT_MODEL "gpt-3.5-turbo-0613" +#define DEFAULT_OAICOMPAT_MODEL "gpt-3.5-turbo" using json = nlohmann::ordered_json; From 220cf7f7809e4d69cd6322c7d315b80a5650b147 Mon Sep 17 00:00:00 2001 From: MichelleTPY Date: Fri, 13 Dec 2024 19:22:15 +0000 Subject: [PATCH 2/4] Add unit test to check `has_new_line` JSON response --- examples/server/tests/unit/test_completion.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/server/tests/unit/test_completion.py b/examples/server/tests/unit/test_completion.py index 7f4f9cd038be4..c4ae81fec31ea 100644 --- a/examples/server/tests/unit/test_completion.py +++ b/examples/server/tests/unit/test_completion.py @@ -25,6 +25,7 @@ def test_completion(prompt: str, n_predict: int, re_content: str, n_prompt: int, assert res.body["timings"]["prompt_n"] == n_prompt assert res.body["timings"]["predicted_n"] == n_predicted assert res.body["truncated"] == truncated + assert res.body["has_new_line"] == False assert match_regex(re_content, res.body["content"]) @@ -47,6 +48,7 @@ def test_completion_stream(prompt: str, n_predict: int, re_content: str, n_promp assert data["timings"]["prompt_n"] == n_prompt assert data["timings"]["predicted_n"] == n_predicted assert data["truncated"] == truncated + assert data["has_new_line"] == False assert data["stop_type"] == "limit" assert "generation_settings" in data assert server.n_predict is not None From 29e6298d2ebaf4a6b1b412b1274aa35b66d1f38a Mon Sep 17 00:00:00 2001 From: MichelleTPY Date: Sat, 14 Dec 2024 00:36:33 +0000 Subject: [PATCH 3/4] Remove `has_new_line` unit test changes. --- examples/server/tests/unit/test_completion.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/server/tests/unit/test_completion.py b/examples/server/tests/unit/test_completion.py index c4ae81fec31ea..7f4f9cd038be4 100644 --- a/examples/server/tests/unit/test_completion.py +++ b/examples/server/tests/unit/test_completion.py @@ -25,7 +25,6 @@ def test_completion(prompt: str, n_predict: int, re_content: str, n_prompt: int, assert res.body["timings"]["prompt_n"] == n_prompt assert res.body["timings"]["predicted_n"] == n_predicted assert res.body["truncated"] == truncated - assert res.body["has_new_line"] == False assert match_regex(re_content, res.body["content"]) @@ -48,7 +47,6 @@ def test_completion_stream(prompt: str, n_predict: int, re_content: str, n_promp assert data["timings"]["prompt_n"] == n_prompt assert data["timings"]["predicted_n"] == n_predicted assert data["truncated"] == truncated - assert data["has_new_line"] == False assert data["stop_type"] == "limit" assert "generation_settings" in data assert server.n_predict is not None From 7db99a044eb6b9fa76d9dfb80bfdf970d1d47793 Mon Sep 17 00:00:00 2001 From: MichelleTPY Date: Sat, 14 Dec 2024 12:05:39 +0000 Subject: [PATCH 4/4] Address code review comment: type check for `has_new_line` in unit test --- examples/server/tests/unit/test_completion.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/server/tests/unit/test_completion.py b/examples/server/tests/unit/test_completion.py index 7f4f9cd038be4..062ebcd4a05cc 100644 --- a/examples/server/tests/unit/test_completion.py +++ b/examples/server/tests/unit/test_completion.py @@ -25,6 +25,7 @@ def test_completion(prompt: str, n_predict: int, re_content: str, n_prompt: int, assert res.body["timings"]["prompt_n"] == n_prompt assert res.body["timings"]["predicted_n"] == n_predicted assert res.body["truncated"] == truncated + assert type(res.body["has_new_line"]) == bool assert match_regex(re_content, res.body["content"]) @@ -48,6 +49,7 @@ def test_completion_stream(prompt: str, n_predict: int, re_content: str, n_promp assert data["timings"]["predicted_n"] == n_predicted assert data["truncated"] == truncated assert data["stop_type"] == "limit" + assert type(data["has_new_line"]) == bool assert "generation_settings" in data assert server.n_predict is not None assert data["generation_settings"]["n_predict"] == min(n_predict, server.n_predict)