From c66b1a7611a90cb0bafc03f6413125a777280c8c Mon Sep 17 00:00:00 2001 From: Reza Kakhki Date: Tue, 24 Dec 2024 15:56:18 +0100 Subject: [PATCH] fix base64 test --- examples/server/tests/unit/test_embedding.py | 2 +- examples/server/utils.hpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/server/tests/unit/test_embedding.py b/examples/server/tests/unit/test_embedding.py index 517525c48..98bec2c2f 100644 --- a/examples/server/tests/unit/test_embedding.py +++ b/examples/server/tests/unit/test_embedding.py @@ -202,7 +202,7 @@ def test_embedding_openai_library_base64(): server.start() test_input = "Test base64 embedding output" - res = server.make_request("POST", "/embeddings", data={ + res = server.make_request("POST", "/v1/embeddings", data={ "input": test_input, "encoding_format": "base64" }) diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp index 43520659c..9c1140750 100644 --- a/examples/server/utils.hpp +++ b/examples/server/utils.hpp @@ -3,6 +3,7 @@ #include "common.h" #include "log.h" #include "llama.h" +#include "common/base64.hpp" #ifndef NDEBUG // crash the server in debug mode, otherwise send an http 500 error @@ -596,6 +597,8 @@ static json format_embeddings_response_oaicompat(const json & request, const jso int32_t n_tokens = 0; int i = 0; for (const auto & elem : embeddings) { + json embedding_obj; + if (use_base64) { const auto& vec = json_value(elem, "embedding", json::array()).get>(); const char* data_ptr = reinterpret_cast(vec.data());