0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

modules/console: Add gpt suite.

This commit is contained in:
Jason Volk 2021-03-29 18:21:22 -07:00
parent 4ac7e1b19d
commit 5e52f6b97b

View file

@ -17297,3 +17297,69 @@ console_cmd__app__signal(opt &out, const string_view &line)
out << "not found." << std::endl;
return true;
}
//
// gpt
//
bool
console_cmd__gpt__raw(opt &out, const string_view &line)
{
const params param{line, " ",
{
"limit"
}};
const auto text
{
tokens_after(line, " ", 0)
};
const unique_mutable_buffer buf
{
2048, 64
};
gpt::opts opts;
opts.limit = param.at<uint>("limit");
opts.top_k = 3;
gpt::task task;
const auto output
{
gpt::generate(buf, text, &opts, &task)
};
out
<< output
<< std::endl;
return true;
}
bool
console_cmd__gpt(opt &out, const string_view &line)
{
return console_cmd__gpt__raw(out, line);
}
bool
console_cmd__gpt__token(opt &out, const string_view &line)
{
const params param{line, " ",
{
"idx"
}};
const auto idx
{
param.at<ushort>("idx")
};
char buf[512];
out
<< gpt::vocab::debug(buf, idx)
<< std::endl;
return true;
}