llama

Форк
0
/
gen-docs.cpp 
52 строки · 1.5 Кб
1
#include "arg.h"
2
#include "common.h"
3

4
#include <fstream>
5
#include <string>
6

7
// Export usage message (-h) to markdown format
8

9
static void export_md(std::string fname, llama_example ex) {
10
    std::ofstream file(fname, std::ofstream::out | std::ofstream::trunc);
11

12
    gpt_params params;
13
    auto ctx_arg = gpt_params_parser_init(params, ex);
14

15
    file << "| Argument | Explanation |\n";
16
    file << "| -------- | ----------- |\n";
17
    for (auto & opt : ctx_arg.options) {
18
        file << "| `";
19
        // args
20
        for (const auto & arg : opt.args) {
21
        if (arg == opt.args.front()) {
22
                file << arg;
23
                if (opt.args.size() > 1) file << ", ";
24
            } else {
25
                file << arg << (arg != opt.args.back() ? ", " : "");
26
            }
27
        }
28
        // value hint
29
        if (opt.value_hint) {
30
            std::string md_value_hint(opt.value_hint);
31
            string_replace_all(md_value_hint, "|", "\\|");
32
            file << " " << md_value_hint;
33
        }
34
        if (opt.value_hint_2) {
35
            std::string md_value_hint_2(opt.value_hint_2);
36
            string_replace_all(md_value_hint_2, "|", "\\|");
37
            file << " " << md_value_hint_2;
38
        }
39
        // help text
40
        std::string md_help(opt.help);
41
        string_replace_all(md_help, "\n", "<br/>");
42
        string_replace_all(md_help, "|", "\\|");
43
        file << "` | " << md_help << " |\n";
44
    }
45
}
46

47
int main(int, char **) {
48
    export_md("autogen-main.md", LLAMA_EXAMPLE_MAIN);
49
    export_md("autogen-server.md", LLAMA_EXAMPLE_SERVER);
50

51
    return 0;
52
}
53

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.