char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Sigbjørn Skjæretcli : add command and file auto-completion (#19985)b5ed0e058

char/aliceai-t5-moe
1.1 KiB46 linesraw
1// Console functions
2
3#pragma once
4
5#include "common.h"
6
7#include <functional>
8#include <string>
9#include <vector>
10
11enum display_type {
12    DISPLAY_TYPE_RESET = 0,
13    DISPLAY_TYPE_INFO,
14    DISPLAY_TYPE_PROMPT,
15    DISPLAY_TYPE_REASONING,
16    DISPLAY_TYPE_USER_INPUT,
17    DISPLAY_TYPE_ERROR
18};
19
20namespace console {
21    void init(bool use_simple_io, bool use_advanced_display);
22    void cleanup();
23    void set_display(display_type display);
24    bool readline(std::string & line, bool multiline_input);
25
26    using completion_callback = std::function<std::vector<std::pair<std::string, size_t>>(std::string_view, size_t)>;
27    void set_completion_callback(completion_callback cb);
28
29    namespace spinner {
30        void start();
31        void stop();
32    }
33
34    // note: the logging API below output directly to stdout
35    // it can negatively impact performance if used on inference thread
36    // only use in in a dedicated CLI thread
37    // for logging in inference thread, use log.h instead
38
39    LLAMA_COMMON_ATTRIBUTE_FORMAT(1, 2)
40    void log(const char * fmt, ...);
41
42    LLAMA_COMMON_ATTRIBUTE_FORMAT(1, 2)
43    void error(const char * fmt, ...);
44
45    void flush();
46}