/*
  SPDX-FileCopyrightText: 2026 Laurent Montel <montel@kde.org>

  SPDX-License-Identifier: GPL-2.0-or-later
*/

#pragma once
#include "plugincommonsettings.h"
#include "textautogenerateollamacommon_export.h"
#include <QString>
#include <QUrl>
class QDebug;
class KConfigGroup;
class TEXTAUTOGENERATEOLLAMACOMMON_EXPORT OllamaCommonSettings : public PluginCommonSettings
{
    Q_GADGET
public:
    enum class KeepAliveType : uint8_t {
        Unknown = 0,
        KeepAliveForever,
        UnloadAfterUse,
        SetTimer,
    };
    Q_ENUM(KeepAliveType)
    OllamaCommonSettings();
    virtual ~OllamaCommonSettings();

    [[nodiscard]] int seed() const;
    void setSeed(int newSeed);

    [[nodiscard]] int keepAliveMinutes() const;
    void setKeepAliveMinutes(int newKeepAliveMinutes);

    void load(const KConfigGroup &config) override;
    void save(KConfigGroup &config) override;

    [[nodiscard]] OllamaCommonSettings::KeepAliveType keepAliveType() const;
    void setKeepAliveType(OllamaCommonSettings::KeepAliveType newKeepAliveType);

    [[nodiscard]] static QString convertKeepAliveTypeToString(OllamaCommonSettings::KeepAliveType type);
    [[nodiscard]] static OllamaCommonSettings::KeepAliveType convertKeepAliveTypeFromString(const QString &str);

    [[nodiscard]] qint64 contextWindowSize() const;
    void setContextWindowSize(qint64 newContextWindowSize);

    [[nodiscard]] int defaultSeed() const;
    [[nodiscard]] int defaultKeepAliveMinutes() const;
    [[nodiscard]] qint64 defaultContextWindowSize() const;
    [[nodiscard]] bool defaultThoughtProcessing() const;
    [[nodiscard]] OllamaCommonSettings::KeepAliveType defaultKeepAliveType() const;

    [[nodiscard]] bool operator==(const OllamaCommonSettings &other) const;

private:
    int mSeed = 0;
    double mTemperature = 0.8;
    int mKeepAliveMinutes = 1;
    qint64 mContextWindowSize = 16384;
    OllamaCommonSettings::KeepAliveType mKeepAliveType = KeepAliveType::Unknown;
};
TEXTAUTOGENERATEOLLAMACOMMON_EXPORT QDebug operator<<(QDebug d, const OllamaCommonSettings &t);
