///
/// HybridLLMSpec.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#if __has_include(<NitroModules/HybridObject.hpp>)
#include <NitroModules/HybridObject.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

// Forward declaration of `LLMLoadOptions` to properly resolve imports.
namespace margelo::nitro::mlxreactnative { struct LLMLoadOptions; }
// Forward declaration of `GenerationStats` to properly resolve imports.
namespace margelo::nitro::mlxreactnative { struct GenerationStats; }
// Forward declaration of `LLMMessage` to properly resolve imports.
namespace margelo::nitro::mlxreactnative { struct LLMMessage; }

#include <string>
#include <NitroModules/Promise.hpp>
#include "LLMLoadOptions.hpp"
#include <optional>
#include <functional>
#include "GenerationStats.hpp"
#include "LLMMessage.hpp"
#include <vector>

namespace margelo::nitro::mlxreactnative {

  using namespace margelo::nitro;

  /**
   * An abstract base class for `LLM`
   * Inherit this class to create instances of `HybridLLMSpec` in C++.
   * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
   * @example
   * ```cpp
   * class HybridLLM: public HybridLLMSpec {
   * public:
   *   HybridLLM(...): HybridObject(TAG) { ... }
   *   // ...
   * };
   * ```
   */
  class HybridLLMSpec: public virtual HybridObject {
    public:
      // Constructor
      explicit HybridLLMSpec(): HybridObject(TAG) { }

      // Destructor
      ~HybridLLMSpec() override = default;

    public:
      // Properties
      virtual bool getIsLoaded() = 0;
      virtual bool getIsGenerating() = 0;
      virtual std::string getModelId() = 0;
      virtual bool getDebug() = 0;
      virtual void setDebug(bool debug) = 0;
      virtual std::string getSystemPrompt() = 0;
      virtual void setSystemPrompt(const std::string& systemPrompt) = 0;

    public:
      // Methods
      virtual std::shared_ptr<Promise<void>> load(const std::string& modelId, const std::optional<LLMLoadOptions>& options) = 0;
      virtual std::shared_ptr<Promise<std::string>> generate(const std::string& prompt) = 0;
      virtual std::shared_ptr<Promise<std::string>> stream(const std::string& prompt, const std::function<void(const std::string& /* token */)>& onToken, const std::optional<std::function<void(const std::string& /* toolName */, const std::string& /* args */)>>& onToolCall) = 0;
      virtual std::shared_ptr<Promise<std::string>> streamWithEvents(const std::string& prompt, const std::function<void(const std::string& /* eventJson */)>& onEvent) = 0;
      virtual void stop() = 0;
      virtual void unload() = 0;
      virtual GenerationStats getLastGenerationStats() = 0;
      virtual std::vector<LLMMessage> getHistory() = 0;
      virtual void clearHistory() = 0;

    protected:
      // Hybrid Setup
      void loadHybridMethods() override;

    protected:
      // Tag for logging
      static constexpr auto TAG = "LLM";
  };

} // namespace margelo::nitro::mlxreactnative
