YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ILLMTest.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef ILLMTEST_H
7#define ILLMTEST_H
8
9#include <yarp/dev/ILLM.h>
11
12#include <catch2/catch_amalgamated.hpp>
13
14using namespace yarp::dev;
15
16namespace yarp::dev::tests {
18{
19 REQUIRE(illm != nullptr);
20
21 bool b;
22
23 b = illm->setPrompt("A prompt");
24 CHECK(b);
25
26 std::string prompt;
27 b = illm->readPrompt(prompt);
28 CHECK(b);
29
31 b = illm->ask("A question", answer);
32 CHECK(b);
33 CHECK(answer.type == "assistant");
34 CHECK(answer.content != "");
35 CHECK(answer.parameters.empty()); // No parameters in a non-function call
36 CHECK(answer.arguments.empty()); // No arguments in a non-function call
37
38 // The fake device returns a function_call if the question is "function"
39 b = illm->ask("function", answer);
40 CHECK(b);
41 CHECK(answer.type == "function");
42 CHECK(answer.content != "");
43 CHECK(!answer.parameters.empty());
44 CHECK(!answer.arguments.empty());
45
46
47 std::vector<yarp::dev::LLM_Message> conversation;
48 b = illm->getConversation(conversation);
49 CHECK(b);
50
51 b = illm->refreshConversation();
52 CHECK(b);
53
54 b = illm->readPrompt(prompt);
55 CHECK(b);
56
57 b = illm->deleteConversation();
58 CHECK(b);
59}
60}
61
62#endif
ILLM interface.
Definition ILLM.h:26
virtual yarp::dev::ReturnValue deleteConversation()=0
Delete the conversation and clear the system context from any internally stored context.
virtual yarp::dev::ReturnValue setPrompt(const std::string &prompt)=0
Performs a question.
virtual yarp::dev::ReturnValue getConversation(std::vector< yarp::dev::LLM_Message > &conversation)=0
Retrieves the whole conversation.
virtual yarp::dev::ReturnValue refreshConversation()=0
Refresh the conversation.
virtual yarp::dev::ReturnValue readPrompt(std::string &oPrompt)=0
Retrieves the provided prompt.
virtual yarp::dev::ReturnValue ask(const std::string &question, yarp::dev::LLM_Message &answer)=0
Performs a question.
std::vector< std::string > parameters
possible parameters
Definition LLM_Message.h:37
std::string type
type of message (can be prompt, assistant, function, ...)
Definition LLM_Message.h:29
std::string content
content of the message
Definition LLM_Message.h:33
std::vector< std::string > arguments
possible arguments of the parameters
Definition LLM_Message.h:41
void exec_iLLM_test_1(yarp::dev::ILLM *illm)
Definition ILLMTest.h:17
For streams capable of holding different kinds of content, check what they actually have.