ResponseBuilder implementation
| 164 | |
| 165 | // ResponseBuilder implementation |
| 166 | std::string ResponseBuilder::buildSuccessResponse(const std::string& content, |
| 167 | const std::string& model, |
| 168 | int prompt_tokens, |
| 169 | int completion_tokens) { |
| 170 | nlohmann::json response = { |
| 171 | {"id", "chatcmpl-test123"}, |
| 172 | {"object", "chat.completion"}, |
| 173 | {"created", 1234567890}, |
| 174 | {"model", model}, |
| 175 | {"system_fingerprint", "fp_test123"}, |
| 176 | {"choices", |
| 177 | nlohmann::json::array( |
| 178 | {{{"index", 0}, |
| 179 | {"message", {{"role", "assistant"}, {"content", content}}}, |
| 180 | {"finish_reason", "stop"}, |
| 181 | {"logprobs", nullptr}}})}, |
| 182 | {"usage", |
| 183 | {{"prompt_tokens", prompt_tokens}, |
| 184 | {"completion_tokens", completion_tokens}, |
| 185 | {"total_tokens", prompt_tokens + completion_tokens}}}}; |
| 186 | |
| 187 | return response.dump(); |
| 188 | } |
| 189 | |
| 190 | std::string ResponseBuilder::buildErrorResponse(int status_code, |
| 191 | const std::string& error_type, |
nothing calls this directly
no outgoing calls
no test coverage detected