-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
73 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ llama-batched-swift | |
/rpc-server | ||
out/ | ||
tmp/ | ||
autogen-*.md | ||
|
||
# Deprecated | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
set(TARGET llama-export-docs) | ||
add_executable(${TARGET} export-docs.cpp) | ||
install(TARGETS ${TARGET} RUNTIME) | ||
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT}) | ||
target_compile_features(${TARGET} PRIVATE cxx_std_11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "common.h" | ||
#include "llama.h" | ||
|
||
#include <cmath> | ||
#include <cstdio> | ||
#include <fstream> | ||
#include <string> | ||
#include <vector> | ||
|
||
// Export usage message (-h) to markdown format | ||
|
||
static void export_md(std::string fname, llama_example ex) { | ||
std::ofstream file(fname, std::ofstream::out | std::ofstream::trunc); | ||
|
||
gpt_params params; | ||
auto options = gpt_params_parser_init(params, ex); | ||
|
||
file << "| Argument | Explanation |\n"; | ||
file << "| -------- | ----------- |\n"; | ||
for (auto & opt : options) { | ||
file << "| `"; | ||
// args | ||
for (const auto & arg : opt.args) { | ||
if (arg == opt.args.front()) { | ||
file << (opt.args.size() == 1 ? arg : (arg + ", ")); | ||
} else { | ||
file << arg << (arg != opt.args.back() ? ", " : ""); | ||
} | ||
} | ||
// value hint | ||
std::string md_value_hint(opt.value_hint); | ||
string_replace_all(md_value_hint, "|", "\\|"); | ||
file << " " << md_value_hint; | ||
// help text | ||
std::string md_help(opt.help); | ||
string_replace_all(md_help, "\n", "<br/>"); | ||
string_replace_all(md_help, "|", "\\|"); | ||
file << "` | " << md_help << " |\n"; | ||
} | ||
} | ||
|
||
int main(int, char **) { | ||
export_md("autogen-main.md", LLAMA_EXAMPLE_MAIN); | ||
export_md("autogen-server.md", LLAMA_EXAMPLE_SERVER); | ||
|
||
return 0; | ||
} |