package dev.mokksy.aimocks.ollama

import io.github.oshai.kotlinlogging.KotlinLogging
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import kotlin.random.Random

val mockOllama = MockOllama(verbose = true)

internal abstract class AbstractMockOllamaTest {
    protected var temperatureValue: Double = -1.0
    protected var seedValue: Int = 42
    protected var topPValue: Double = -1.0
    protected var topKValue: Long = -1
    protected var maxTokensValue: Long = -1
    protected lateinit var modelName: String
    protected lateinit var embeddingModelName: String
    protected val logger = KotlinLogging.logger(name = this::class.simpleName!!)
    protected lateinit var startTimestamp: java.time.Instant

    @BeforeEach
    fun beforeEach() {
        seedValue = Random.nextInt(1, 100500)
        modelName = "llama3-$seedValue"
        embeddingModelName = "all-minilm-$seedValue"
        topPValue = Random.nextDouble(0.1, 1.0)
        topKValue = Random.nextLong(1, 999)
        temperatureValue = Random.nextDouble(0.0, 1.0)
        maxTokensValue = Random.nextLong(512, 8000)
        startTimestamp = java.time.Instant.now()
    }

    @AfterEach
    fun afterEach() {
        mockOllama.verifyNoUnexpectedRequests()
    }
}
