YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
main.cpp
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
7
8#include <ConversationModel.h>
9#include <QGuiApplication>
10#include <QQmlApplicationEngine>
11#include <QQmlContext>
12#include <QQuickView>
13
25int main(int argc, char* argv[])
26{
27
28 QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
29 QGuiApplication app(argc, argv);
30
31 qmlRegisterType<ConversationModel>("conversationmodel", 1, 0, "ConversationModel");
32 ConversationModel aConversationModel;
33
34 // Load configuration
36 rf.setDefaultConfigFile("config.ini");
37 rf.setDefaultContext("yarpllmgui");
38 rf.configure(argc, argv);
39 std::string remote_rpc = rf.check("remote_rpc", yarp::os::Value("/yarpgpt/rpc")).asString();
40 std::string streaming_port = rf.check("streaming_port", yarp::os::Value("/yarpllm/conv:o")).asString();
41
42 // Configuration based on user's input from resource finder. Can be changed from ui.
43 aConversationModel.configure(remote_rpc, streaming_port);
44 aConversationModel.refreshConversation();
45
46 QQmlApplicationEngine engine;
47 engine.rootContext()->setContextProperty("aConversationModel", &aConversationModel);
48 engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
49 if (engine.rootObjects().isEmpty())
50 return -1;
51
52 int ret;
53 try {
54 ret = app.exec();
55 } catch (const std::bad_alloc&) {
56 yError() << "Failure during application";
57 return EXIT_FAILURE;
58 }
59
60 return ret;
61}
bool ret
#define yError(...)
Definition Log.h:361
The model of the conversation data in the ui.
void refreshConversation()
Deletes and reuploads the conversation.
bool configure(const std::string &remote_rpc, const std::string &streaming_port_name)
Configures the remote rpc and streaming port.
Helper class for finding config files and other external resources.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
bool setDefaultContext(const std::string &contextName)
Sets the context for the current ResourceFinder object.
bool configure(int argc, char *argv[], bool skipFirstArgument=true)
Sets up the ResourceFinder.
bool setDefaultConfigFile(const std::string &fname)
Provide a default value for the configuration file (can be overridden from command line with the –fro...
A single value (typically within a Bottle).
Definition Value.h:43
int main(int argc, char *argv[])
Definition main.cpp:385