///
/// LLMGenerationConfig.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/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif



#include <optional>

namespace margelo::nitro::mlxreactnative {

  /**
   * A struct which can be represented as a JavaScript object (LLMGenerationConfig).
   */
  struct LLMGenerationConfig final {
  public:
    std::optional<double> maxTokens     SWIFT_PRIVATE;
    std::optional<double> maxKVSize     SWIFT_PRIVATE;
    std::optional<double> kvBits     SWIFT_PRIVATE;
    std::optional<double> kvGroupSize     SWIFT_PRIVATE;
    std::optional<double> quantizedKVStart     SWIFT_PRIVATE;
    std::optional<double> temperature     SWIFT_PRIVATE;
    std::optional<double> topP     SWIFT_PRIVATE;
    std::optional<double> repetitionPenalty     SWIFT_PRIVATE;
    std::optional<double> repetitionContextSize     SWIFT_PRIVATE;
    std::optional<double> prefillStepSize     SWIFT_PRIVATE;

  public:
    LLMGenerationConfig() = default;
    explicit LLMGenerationConfig(std::optional<double> maxTokens, std::optional<double> maxKVSize, std::optional<double> kvBits, std::optional<double> kvGroupSize, std::optional<double> quantizedKVStart, std::optional<double> temperature, std::optional<double> topP, std::optional<double> repetitionPenalty, std::optional<double> repetitionContextSize, std::optional<double> prefillStepSize): maxTokens(maxTokens), maxKVSize(maxKVSize), kvBits(kvBits), kvGroupSize(kvGroupSize), quantizedKVStart(quantizedKVStart), temperature(temperature), topP(topP), repetitionPenalty(repetitionPenalty), repetitionContextSize(repetitionContextSize), prefillStepSize(prefillStepSize) {}

  public:
    friend bool operator==(const LLMGenerationConfig& lhs, const LLMGenerationConfig& rhs) = default;
  };

} // namespace margelo::nitro::mlxreactnative

namespace margelo::nitro {

  // C++ LLMGenerationConfig <> JS LLMGenerationConfig (object)
  template <>
  struct JSIConverter<margelo::nitro::mlxreactnative::LLMGenerationConfig> final {
    static inline margelo::nitro::mlxreactnative::LLMGenerationConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::mlxreactnative::LLMGenerationConfig(
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxTokens"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxKVSize"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kvBits"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kvGroupSize"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quantizedKVStart"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "temperature"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "topP"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "repetitionPenalty"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "repetitionContextSize"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "prefillStepSize")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::mlxreactnative::LLMGenerationConfig& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "maxTokens"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxTokens));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "maxKVSize"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxKVSize));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "kvBits"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.kvBits));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "kvGroupSize"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.kvGroupSize));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "quantizedKVStart"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.quantizedKVStart));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "temperature"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.temperature));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "topP"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.topP));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "repetitionPenalty"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.repetitionPenalty));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "repetitionContextSize"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.repetitionContextSize));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "prefillStepSize"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.prefillStepSize));
      return obj;
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isObject()) {
        return false;
      }
      jsi::Object obj = value.getObject(runtime);
      if (!nitro::isPlainObject(runtime, obj)) {
        return false;
      }
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxTokens")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxKVSize")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kvBits")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kvGroupSize")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quantizedKVStart")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "temperature")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "topP")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "repetitionPenalty")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "repetitionContextSize")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "prefillStepSize")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
