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

import Foundation
import NitroModules

/// See ``HybridLLMSpec``
public protocol HybridLLMSpec_protocol: HybridObject {
  // Properties
  var isLoaded: Bool { get }
  var isGenerating: Bool { get }
  var modelId: String { get }
  var debug: Bool { get set }
  var systemPrompt: String { get set }
  var maxTokens: Double { get set }
  var temperature: Double { get set }
  var enableThinking: Bool { get set }

  // Methods
  func load(modelId: String, options: LLMLoadOptions?) throws -> Promise<Void>
  func generate(prompt: String) throws -> Promise<String>
  func stream(prompt: String, onToken: @escaping (_ token: String) -> Void, onToolCall: ((_ toolName: String, _ args: String) -> Void)?) throws -> Promise<String>
  func streamWithEvents(prompt: String, onEvent: @escaping (_ eventJson: String) -> Void) throws -> Promise<String>
  func stop() throws -> Void
  func unload() throws -> Void
  func getLastGenerationStats() throws -> GenerationStats
  func getHistory() throws -> [LLMMessage]
  func clearHistory() throws -> Void
}

public extension HybridLLMSpec_protocol {
  /// Default implementation of ``HybridObject.toString``
  func toString() -> String {
    return "[HybridObject LLM]"
  }
}

/// See ``HybridLLMSpec``
open class HybridLLMSpec_base {
  private weak var cxxWrapper: HybridLLMSpec_cxx? = nil
  public init() { }
  public func getCxxWrapper() -> HybridLLMSpec_cxx {
  #if DEBUG
    guard self is HybridLLMSpec else {
      fatalError("`self` is not a `HybridLLMSpec`! Did you accidentally inherit from `HybridLLMSpec_base` instead of `HybridLLMSpec`?")
    }
  #endif
    if let cxxWrapper = self.cxxWrapper {
      return cxxWrapper
    } else {
      let cxxWrapper = HybridLLMSpec_cxx(self as! HybridLLMSpec)
      self.cxxWrapper = cxxWrapper
      return cxxWrapper
    }
  }
}

/**
 * A Swift base-protocol representing the LLM HybridObject.
 * Implement this protocol to create Swift-based instances of LLM.
 * ```swift
 * class HybridLLM : HybridLLMSpec {
 *   // ...
 * }
 * ```
 */
public typealias HybridLLMSpec = HybridLLMSpec_protocol & HybridLLMSpec_base
