C++ / fmt (pull_request) Failing after 4s
C++ / build (pull_request) Failing after 9s
JS/TS / lint (pull_request) Successful in 9s
JS/TS / fmt (pull_request) Successful in 16s
C++ / clang-tidy (pull_request) Failing after 43s
Python / static (pull_request) Failing after 57s
Rust / fmt (pull_request) Successful in 1m30s
Rust / build (pull_request) Successful in 2m5s
Rust / clippy (pull_request) Successful in 1m55s
Python / verify (pull_request) Successful in 2m23s
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <QJsonArray>
|
|
#include <QJsonObject>
|
|
#include <QList>
|
|
#include <QObject>
|
|
#include <QString>
|
|
|
|
#include <functional>
|
|
|
|
namespace ZShell::llm {
|
|
|
|
class LlmTool : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit LlmTool(QObject* parent = nullptr);
|
|
~LlmTool() override;
|
|
|
|
[[nodiscard]] virtual QString name() const = 0;
|
|
[[nodiscard]] virtual QString description() const = 0;
|
|
[[nodiscard]] virtual QJsonObject parameters() const = 0;
|
|
|
|
virtual void execute(
|
|
const QJsonObject& args,
|
|
std::function<void(const QJsonObject& result)> done) = 0;
|
|
virtual void cancel();
|
|
|
|
[[nodiscard]] QJsonObject specification() const;
|
|
};
|
|
|
|
class ToolRegistry : public QObject {
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
|
|
|
|
public:
|
|
explicit ToolRegistry(QObject* parent = nullptr);
|
|
|
|
[[nodiscard]] bool enabled() const { return m_enabled; }
|
|
void setEnabled(bool value);
|
|
|
|
void registerTool(LlmTool* tool);
|
|
[[nodiscard]] LlmTool* tool(const QString& name) const;
|
|
[[nodiscard]] QJsonArray specifications() const;
|
|
void cancelAll();
|
|
|
|
Q_SIGNALS:
|
|
void enabledChanged();
|
|
|
|
private:
|
|
bool m_enabled = true;
|
|
QList<LlmTool*> m_tools;
|
|
};
|
|
|
|
} // namespace ZShell::llm
|