mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
f4fb3df437
Signed-off-by: Adam Treat <treat.adam@gmail.com>
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
#ifndef BRAVESEARCH_H
|
|
#define BRAVESEARCH_H
|
|
|
|
#include "sourceexcerpt.h"
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QNetworkAccessManager>
|
|
#include <QNetworkReply>
|
|
|
|
class BraveAPIWorker : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
BraveAPIWorker()
|
|
: QObject(nullptr)
|
|
, m_networkManager(nullptr)
|
|
, m_topK(1) {}
|
|
virtual ~BraveAPIWorker() {}
|
|
|
|
QPair<QString, QList<SourceExcerpt>> response() const { return m_response; }
|
|
|
|
public Q_SLOTS:
|
|
void request(const QString &apiKey, const QString &query, int topK);
|
|
|
|
Q_SIGNALS:
|
|
void finished();
|
|
|
|
private Q_SLOTS:
|
|
void handleFinished();
|
|
void handleErrorOccurred(QNetworkReply::NetworkError code);
|
|
|
|
private:
|
|
QNetworkAccessManager *m_networkManager;
|
|
QPair<QString, QList<SourceExcerpt>> m_response;
|
|
int m_topK;
|
|
};
|
|
|
|
class BraveSearch : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
BraveSearch()
|
|
: QObject(nullptr) {}
|
|
virtual ~BraveSearch() {}
|
|
|
|
QPair<QString, QList<SourceExcerpt>> search(const QString &apiKey, const QString &query, int topK, unsigned long timeout = 2000);
|
|
|
|
Q_SIGNALS:
|
|
void request(const QString &apiKey, const QString &query, int topK);
|
|
};
|
|
|
|
#endif // BRAVESEARCH_H
|