now actually works
This commit is contained in:
parent
83264db09d
commit
f5650475c7
@ -121,7 +121,12 @@ std::string LlamaCppWeb::completeLine(const std::string_view prompt) {
|
|||||||
{"stop", {"\n"}},
|
{"stop", {"\n"}},
|
||||||
});
|
});
|
||||||
|
|
||||||
return ret.dump();
|
if (ret.empty() || ret.count("content") == 0) {
|
||||||
|
// error
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret.at("content");
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json LlamaCppWeb::complete(const nlohmann::json& request_j) {
|
nlohmann::json LlamaCppWeb::complete(const nlohmann::json& request_j) {
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <solanaceae/util/utils.hpp>
|
#include <solanaceae/util/utils.hpp>
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <future>
|
#include <future>
|
||||||
@ -101,7 +102,7 @@ void RPBot::stateTransition(const Contact3 c, const StateIdle& from, StateNext&
|
|||||||
|
|
||||||
template<>
|
template<>
|
||||||
void RPBot::stateTransition(const Contact3, const StateNext&, StateIdle& to) {
|
void RPBot::stateTransition(const Contact3, const StateNext&, StateIdle& to) {
|
||||||
to.timeout = std::uniform_real_distribution<>{15.f, 45.f}(_rng);
|
to.timeout = std::uniform_real_distribution<>{10.f, 45.f}(_rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
@ -110,7 +111,7 @@ void RPBot::stateTransition(const Contact3 c, const StateNext& from, StateGenera
|
|||||||
assert(_cr.all_of<Contact::Components::Self>(c));
|
assert(_cr.all_of<Contact::Components::Self>(c));
|
||||||
const Contact3 self = _cr.get<Contact::Components::Self>(c).self;
|
const Contact3 self = _cr.get<Contact::Components::Self>(c).self;
|
||||||
|
|
||||||
to.prompt += _cr.get<Contact::Components::Name>(self).name + ": "; // TODO: remove space
|
to.prompt += _cr.get<Contact::Components::Name>(self).name + ":"; // TODO: remove space
|
||||||
|
|
||||||
{ // launch async
|
{ // launch async
|
||||||
to.future = std::async(std::launch::async, [&to, this]() -> std::string {
|
to.future = std::async(std::launch::async, [&to, this]() -> std::string {
|
||||||
@ -121,7 +122,7 @@ void RPBot::stateTransition(const Contact3 c, const StateNext& from, StateGenera
|
|||||||
|
|
||||||
template<>
|
template<>
|
||||||
void RPBot::stateTransition(const Contact3, const StateGenerateMsg&, StateIdle& to) {
|
void RPBot::stateTransition(const Contact3, const StateGenerateMsg&, StateIdle& to) {
|
||||||
to.timeout = std::uniform_real_distribution<>{10.f, 30.f}(_rng);
|
to.timeout = std::uniform_real_distribution<>{5.f, 20.f}(_rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
RPBot::RPBot(
|
RPBot::RPBot(
|
||||||
@ -319,13 +320,21 @@ float RPBot::doAllGenerateMsg(float) {
|
|||||||
std::cout << "RPBot: generatemessage compute done!\n";
|
std::cout << "RPBot: generatemessage compute done!\n";
|
||||||
|
|
||||||
std::string msg = state.future.get();
|
std::string msg = state.future.get();
|
||||||
_rmm.sendText(c, msg);
|
if (!msg.empty()) {
|
||||||
|
std::string::size_type start_pos = 0;
|
||||||
|
if (msg.front() == ' ') {
|
||||||
|
start_pos += 1;
|
||||||
|
}
|
||||||
|
_rmm.sendText(c, std::string_view{msg}.substr(start_pos));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: timing check?
|
// TODO: timing check?
|
||||||
// transition to Idle
|
// transition to Idle
|
||||||
emplaceStateTransition<StateIdle>(_cr, c, state);
|
emplaceStateTransition<StateIdle>(_cr, c, state);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_cr.remove<StateGenerateMsg>(to_remove.cbegin(), to_remove.cend());
|
||||||
return min_tick_interval;
|
return min_tick_interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user