14 if(!m_conversation.empty())
16 yError() <<
"The conversation is already ongoing. You must first delete the whole conversation and start from scratch.";
17 return ReturnValue::return_code::return_value_error_method_failed;
26 for (
const auto &message : m_conversation)
28 if (message.type ==
"system")
30 oPrompt = message.content;
35 return ReturnValue::return_code::return_value_error_method_failed;
42 if(question ==
"function")
44 std::string function_name =
"FakeFunction";
45 std::vector<std::string> function_params = {
"arg1",
"arg2"};
46 std::vector<std::string> function_args = {
"yes",
"no"};
51 std::string answer_content =
"Fatti non foste per viver come bruti ma per seguir virtute e canoscenza";
55 m_conversation.push_back(answer);
62 oConversation = m_conversation;
68 m_conversation.clear();
74 std::string current_prompt;
78 yError() <<
"No prompt found in the conversation. Cannot refresh.";
79 return ReturnValue::return_code::return_value_error_method_failed;
86 yError() <<
"Failed to refresh the conversation.";
87 return ReturnValue::return_code::return_value_error_method_failed;
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
yarp::dev::ReturnValue getConversation(std::vector< yarp::dev::LLM_Message > &oConversation) override
Retrieves the whole conversation.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
yarp::dev::ReturnValue ask(const std::string &question, yarp::dev::LLM_Message &oAnswer) override
Performs a question.
yarp::dev::ReturnValue refreshConversation() noexcept override
Refresh the conversation.
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue deleteConversation() noexcept override
Delete the conversation and clear the system context from any internally stored context.
yarp::dev::ReturnValue setPrompt(const std::string &prompt) override
Performs a question.
yarp::dev::ReturnValue readPrompt(std::string &oPromp) override
Retrieves the provided prompt.
A base class for nested structures that can be searched.
For streams capable of holding different kinds of content, check what they actually have.