FluentUI/example/ChatController.h

36 lines
901 B
C
Raw Permalink Normal View History

2023-03-17 14:05:27 +08:00
#ifndef CHATCONTROLLER_H
#define CHATCONTROLLER_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>
2023-03-18 20:20:59 +08:00
#include <QGuiApplication>
#include <QClipboard>
2023-03-17 14:05:27 +08:00
#include <QByteArray>
2023-03-18 22:52:24 +08:00
#include <QFile>
2023-03-17 14:05:27 +08:00
#include "stdafx.h"
class ChatController : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(bool,isLoading)
Q_PROPERTY_AUTO(QString,responseData);
public:
explicit ChatController(QObject *parent = nullptr);
Q_INVOKABLE void sendMessage(const QString& text);
2023-03-18 20:20:59 +08:00
Q_INVOKABLE void clipText(const QString& text);
2023-03-17 17:56:50 +08:00
private:
QJsonObject createMessage(const QString& role,const QString& content);
2023-03-17 14:05:27 +08:00
private:
QNetworkAccessManager* networkManager;
2023-03-17 17:56:50 +08:00
QJsonArray messages;
2023-03-17 14:29:13 +08:00
QString baseKey = "c2stbXgxWm5MQkZ5TzhNYzNmRWl6eDZUM0JsYmtGSnNBWjNiakJjSXB6WGN3QW9KSk11";
2023-03-17 14:05:27 +08:00
};
#endif // CHATCONTROLLER_H