char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
c264f65ff
char/aliceai-t5-moe
1#pragma once 2 3#include <functional> 4#include <string> 5 6// openai-like client for CLI 7struct cli_client { 8std ::string server_base ;// base url, for example "http://127.0.0.1:8080" 9std ::string last_error ;// set when wait_health() fails 10 11std ::string model ;// optional, set when the server has multiple models (router mode) 12 13// simple GET request, returns the raw response body 14// throws std::runtime_error on transport error or non-2xx status 15std ::string get (const std ::string & path ); 16 17// simple POST request, returns the raw response body 18// throws std::runtime_error on transport error or non-2xx status 19std ::string post (const std ::string & path ,const std ::string & body ); 20 21// POST request with an SSE streaming response 22// on_data is invoked per "data:" event with the raw event payload 23// returns after the stream is finished (empty string on graceful exit) 24// otherwise, the raw error response body 25std ::string post_sse (const std ::string & path , 26const std ::string & body , 27const std ::function < bool ()> & should_stop , 28const std ::function < void (const std ::string & )> & on_data ); 29 30// poll /health until the server is ready to accept requests 31// returns false if is_aborted returned true or the server is unreachable 32bool wait_health (const std ::function < bool ()> & is_aborted ); 33};