LearningEngine

Defines the contract for the AI model's learning and inference capabilities.

This interface abstracts the underlying machine learning framework (e.g., KotlinDL, a custom model) from the KarlContainer. Implementations of this interface are responsible for managing the ML model's lifecycle, training, prediction, and state serialization.

Functions

Link copied to clipboard
abstract suspend fun getCurrentState(): KarlContainerState

Retrieves the current, serializable state of the learning model for persistence.

Link copied to clipboard

(Optional but Recommended) Provides insights into the current learning progress. This can be used to power an "AI Maturity Meter" in the UI.

Link copied to clipboard
abstract suspend fun initialize(state: KarlContainerState?, coroutineScope: <Error class: unknown class>)

Initializes the learning engine. This method should prepare the engine for operation, which includes creating a new model or loading an existing one from a saved state.

Link copied to clipboard
abstract suspend fun predict(contextData: List<InteractionData> = emptyList(), instructions: List<KarlInstruction> = emptyList()): Prediction?

Makes a prediction or suggestion based on the current learned state and optional context.

Link copied to clipboard
abstract suspend fun release()

Releases any resources held by the engine, such as native memory used by an ML backend or active coroutine jobs. This should be called when the container is being shut down.

Link copied to clipboard
abstract suspend fun reset()

Resets the learning engine to its initial, untrained "blank slate" state. This should clear any learned parameters and reset the internal model.

Link copied to clipboard
abstract fun trainStep(data: InteractionData): <Error class: unknown class>

Performs a single, incremental training step based on new interaction data.