Felipe97/llama-cpp-compiled
01.1k
1#pragma once2 3#include <functional>4#include <string>5 6// openai-like client for CLI7struct cli_client {8 std::string server_base; // base url, for example "http://127.0.0.1:8080"9 std::string last_error; // set when wait_health() fails10 11 std::string model; // optional, set when the server has multiple models (router mode)12 13 // simple GET request, returns the raw response body14 // throws std::runtime_error on transport error or non-2xx status15 std::string get(const std::string & path);16 17 // simple POST request, returns the raw response body18 // throws std::runtime_error on transport error or non-2xx status19 std::string post(const std::string & path, const std::string & body);20 21 // POST request with an SSE streaming response22 // on_data is invoked per "data:" event with the raw event payload23 // returns after the stream is finished (empty string on graceful exit)24 // otherwise, the raw error response body25 std::string post_sse(const std::string & path,26 const std::string & body,27 const std::function<bool()> & should_stop,28 const std::function<void(const std::string &)> & on_data);29 30 // poll /health until the server is ready to accept requests31 // returns false if is_aborted returned true or the server is unreachable32 bool wait_health(const std::function<bool()> & is_aborted);33};34 