char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
0021a77de
char/aliceai-t5-moe
1#pragma once 2 3#include "server-common.h" 4#include "server-http.h" 5#include "server-queue.h" 6#include "server-mcp.h" 7 8#include <atomic> 9#include <functional> 10#include <memory> 11 12struct server_tool { 13std ::string name ; 14std ::string display_name ; 15bool permission_write = false; 16bool support_stream = false;// if true, output can be streamed 17bool uses_cwd = false;// if true, the tool resolves paths and runs against the working directory 18 19virtual ~server_tool ()= default ; 20virtual json get_definition ()const = 0 ; 21virtual std ::string type ()const {return "server" ; } 22 23struct stream { 24server_response & qr ; 25int id ; 26std ::function < bool ()> alive ; 27void push (const std ::string & chunk ); 28 }; 29virtual json invoke (json params ,stream * st = nullptr )const = 0 ; 30 31json to_json ()const ; 32}; 33 34struct server_tools_runtime ;// impl detail, defined in server-tools.cpp 35 36struct server_tools { 37std ::vector < std ::unique_ptr < server_tool >>tools ; 38 39// for streaming 40server_response queue_res ; 41std ::atomic < int > res_id {0 }; 42 43// set when --tools-runtime is configured; routes every tool call through an isolate 44std ::unique_ptr < server_tools_runtime > runtime ; 45 46void setup (const std ::vector < std ::string > & enabled_tools , 47server_mcp & mcp_mgr , 48const std ::string & tools_runtime ); 49 50server_http_context ::handler_t handle_get ; 51server_http_context ::handler_t handle_post ; 52 53server_tools (); 54 ~server_tools (); 55};