mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
dfe3e951d4
Signed-off-by: Adam Treat <treat.adam@gmail.com>
49 lines
997 B
C++
49 lines
997 B
C++
#ifndef BRAVESEARCH_H
|
|
#define BRAVESEARCH_H
|
|
|
|
#include "sourceexcerpt.h"
|
|
#include "tool.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() {}
|
|
|
|
QString 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;
|
|
QString m_response;
|
|
int m_topK;
|
|
};
|
|
|
|
class BraveSearch : public Tool {
|
|
Q_OBJECT
|
|
public:
|
|
BraveSearch() : Tool() {}
|
|
virtual ~BraveSearch() {}
|
|
|
|
QString run(const QJsonObject ¶meters, qint64 timeout = 2000) override;
|
|
};
|
|
|
|
#endif // BRAVESEARCH_H
|