mirror of
https://github.com/matrix-construct/construct
synced 2024-09-30 04:38:52 +02:00
modules/console: Add gpt tldr cmd diagnostic.
This commit is contained in:
parent
71f0d15910
commit
8839f6d273
1 changed files with 58 additions and 0 deletions
|
@ -17958,3 +17958,61 @@ console_cmd__gpt__label(opt &out, const string_view &line)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
console_cmd__gpt__tldr(opt &out, const string_view &line)
|
||||||
|
{
|
||||||
|
const params param{line, " ",
|
||||||
|
{
|
||||||
|
"event_id", "top_k", "top_p", "limit"
|
||||||
|
}};
|
||||||
|
|
||||||
|
const m::event::id event_id
|
||||||
|
{
|
||||||
|
param["event_id"]
|
||||||
|
};
|
||||||
|
|
||||||
|
const unique_mutable_buffer buf
|
||||||
|
{
|
||||||
|
16_KiB
|
||||||
|
};
|
||||||
|
|
||||||
|
const json::object content
|
||||||
|
{
|
||||||
|
m::get(event_id, "content", buf)
|
||||||
|
};
|
||||||
|
|
||||||
|
const m::room::message msg
|
||||||
|
{
|
||||||
|
content
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto body
|
||||||
|
{
|
||||||
|
msg.body()
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string text(body);
|
||||||
|
text += "\n\nTL;DR:"s;
|
||||||
|
|
||||||
|
gpt::opts opts alignas(4096);
|
||||||
|
opts.top_k = param.at("top_k", opts.top_k);
|
||||||
|
opts.top_p = param.at("top_p", opts.top_p);
|
||||||
|
opts.limit = param.at("limit", opts.limit);
|
||||||
|
|
||||||
|
gpt::ctrl ctrl alignas(4096) {0};
|
||||||
|
gpt::task task
|
||||||
|
{
|
||||||
|
&opts, &ctrl
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto output
|
||||||
|
{
|
||||||
|
task(buf, text)
|
||||||
|
};
|
||||||
|
|
||||||
|
out
|
||||||
|
<< output
|
||||||
|
<< std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue