diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-20 20:10:56 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-21 05:57:19 +0200 |
| commit | 6b969d25ce136eaf695222bd1a10bff1ecac0220 (patch) | |
| tree | c23afb50c28b9deaddae5c6526a74ee11cf2d865 /src/server_json.c | |
| parent | d4bdb8dae753462f621507d5fc3582e0e53da35c (diff) | |
| download | ffwd-6b969d25ce136eaf695222bd1a10bff1ecac0220.tar.gz ffwd-6b969d25ce136eaf695222bd1a10bff1ecac0220.zip | |
all: split Makefile and reorg library/tools
Diffstat (limited to '')
| -rw-r--r-- | tools/server/json.c (renamed from src/server_json.c) | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/server_json.c b/tools/server/json.c index cca8fd3..4812164 100644 --- a/src/server_json.c +++ b/tools/server/json.c @@ -1,5 +1,5 @@ #include "server_internal.h" -#include "server_util.h" +#include "util.h" #include <cjson/cJSON.h> #include <ctype.h> @@ -143,7 +143,7 @@ bool cjson_is_integer(cJSON *item) { } const char *encoding_from_root(cJSON *root, cJSON *detail, embedding_api_t api) { - const char *dflt = api == EMBED_API_PERPLEXITY ? "base64_int8" : "float"; + const char *dflt = api == FFWD_API_PERPLEXITY ? "base64_int8" : "float"; cJSON *encoding = cJSON_GetObjectItemCaseSensitive(root, "encoding_format"); if (!encoding) return dflt; @@ -153,13 +153,12 @@ const char *encoding_from_root(cJSON *root, cJSON *detail, embedding_api_t api) return dflt; } const char *v = encoding->valuestring; - int ok = api == EMBED_API_PERPLEXITY - ? (!strcmp(v, "base64_int8") || !strcmp(v, "base64_binary") || - !strcmp(v, "float")) + int ok = api == FFWD_API_PERPLEXITY + ? (!strcmp(v, "base64_int8") || !strcmp(v, "base64_binary") || !strcmp(v, "float")) : (!strcmp(v, "float") || !strcmp(v, "base64")); if (!ok) { ve_add(detail, "[\"body\",\"encoding_format\"]", - api == EMBED_API_PERPLEXITY + api == FFWD_API_PERPLEXITY ? "value is not a valid enum member; permitted: " "'base64_int8', 'base64_binary', 'float'" : "value is not a valid enum member; permitted: 'float', 'base64'", @@ -182,8 +181,7 @@ int text_type_is_query(cJSON *root, cJSON *detail, const char *query_instruct) { return 0; } if (!cJSON_IsString(tt) || !tt->valuestring) { - ve_add(detail, "[\"body\",\"text_type\"]", "text_type must be a string", - "type_error.string"); + ve_add(detail, "[\"body\",\"text_type\"]", "text_type must be a string", "type_error.string"); return 0; } const char *v = tt->valuestring; @@ -196,8 +194,7 @@ int text_type_is_query(cJSON *root, cJSON *detail, const char *query_instruct) { return 0; } -int dimensions_from_root( - cJSON *root, cJSON *detail, int min_dim, int max_dim, const char *encoding) { +int dimensions_from_root(cJSON *root, cJSON *detail, int min_dim, int max_dim, const char *encoding) { int dims = max_dim; cJSON *dimensions = cJSON_GetObjectItemCaseSensitive(root, "dimensions"); if (dimensions) { @@ -208,8 +205,7 @@ int dimensions_from_root( dims = dimensions->valueint; if (dims < min_dim || dims > max_dim) { char msg[96]; - snprintf(msg, sizeof(msg), "dimensions must be between %d and %d", min_dim, - max_dim); + snprintf(msg, sizeof(msg), "dimensions must be between %d and %d", min_dim, max_dim); ve_add(detail, "[\"body\",\"dimensions\"]", msg, "value_error.range"); } } |
