CoolFace
Modelpublic

Felipe97/llama-cpp-compiled

sourceHugging Faceupdated 3d agoView on Hugging Face
0likes1.1kdownloads
server-tools.h56 linesDownload Raw Back to server
1#pragma once2 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 {13    std::string name;14    std::string display_name;15    bool permission_write = false;16    bool support_stream = false; // if true, output can be streamed17    bool uses_cwd = false;       // if true, the tool resolves paths and runs against the working directory18 19    virtual ~server_tool() = default;20    virtual json get_definition() const = 0;21    virtual std::string type() const { return "server"; }22 23    struct stream {24        server_response & qr;25        int id;26        std::function<bool()> alive;27        void push(const std::string & chunk);28    };29    virtual json invoke(json params, stream * st = nullptr) const = 0;30 31    json to_json() const;32};33 34struct server_tools_runtime; // impl detail, defined in server-tools.cpp35 36struct server_tools {37    std::vector<std::unique_ptr<server_tool>> tools;38 39    // for streaming40    server_response queue_res;41    std::atomic<int> res_id{0};42 43    // set when --tools-runtime is configured; routes every tool call through an isolate44    std::unique_ptr<server_tools_runtime> runtime;45 46    void setup(const std::vector<std::string> & enabled_tools,47               server_mcp & mcp_mgr,48               const std::string & tools_runtime);49 50    server_http_context::handler_t handle_get;51    server_http_context::handler_t handle_post;52 53    server_tools();54    ~server_tools();55};56