]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server: Fix `has_next_line` in JSON response (#10818)
authorMichelle Tan <redacted>
Sat, 14 Dec 2024 22:29:45 +0000 (22:29 +0000)
committerGitHub <redacted>
Sat, 14 Dec 2024 22:29:45 +0000 (23:29 +0100)
* Update server JSON response.

* Add unit test to check `has_new_line` JSON response

* Remove `has_new_line` unit test changes.

* Address code review comment: type check for `has_new_line` in unit test

examples/server/server.cpp
examples/server/tests/unit/test_completion.py
examples/server/utils.hpp

index 210c36e01f826144e9067ac6bb6c94d2c6555885..5cc86bf7c8302f4a21da89a79f0704d479092338 100644 (file)
@@ -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;
 
index 7f4f9cd038be4ba8d2785a2bd21672d54f73f865..062ebcd4a05cce2508a42cbdd7b2fe1187ecf261 100644 (file)
@@ -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)
index 2fcb895abe7e48efb7cd80afaff0bb0152766e68..c6f08bf21071aacdaddae5b79c7ad6e68f558b55 100644 (file)
@@ -22,7 +22,7 @@
 #include <vector>
 #include <memory>
 
-#define DEFAULT_OAICOMPAT_MODEL "gpt-3.5-turbo-0613"
+#define DEFAULT_OAICOMPAT_MODEL "gpt-3.5-turbo"
 
 using json = nlohmann::ordered_json;