/*
 * Ollama4j - Java library for interacting with Ollama server.
 * Copyright (c) 2025 Amith Koujalgi and contributors.
 *
 * Licensed under the MIT License (the "License");
 * you may not use this file except in compliance with the License.
 *
*/
package io.github.ollama4j.models.generate;

import io.github.ollama4j.utils.Options;

/**
 * Helper class for creating {@link OllamaGenerateRequest}
 * objects using the builder-pattern.
 */
public class OllamaGenerateRequestBuilder {

    private OllamaGenerateRequestBuilder(String model, String prompt) {
        request = new OllamaGenerateRequest(model, prompt);
    }

    private OllamaGenerateRequest request;

    public static OllamaGenerateRequestBuilder getInstance(String model) {
        return new OllamaGenerateRequestBuilder(model, "");
    }

    public OllamaGenerateRequest build() {
        return request;
    }

    public OllamaGenerateRequestBuilder withPrompt(String prompt) {
        request.setPrompt(prompt);
        return this;
    }

    public OllamaGenerateRequestBuilder withGetJsonResponse() {
        this.request.setFormat("json");
        return this;
    }

    public OllamaGenerateRequestBuilder withOptions(Options options) {
        this.request.setOptions(options.getOptionsMap());
        return this;
    }

    public OllamaGenerateRequestBuilder withTemplate(String template) {
        this.request.setTemplate(template);
        return this;
    }

    public OllamaGenerateRequestBuilder withStreaming() {
        this.request.setStream(true);
        return this;
    }

    public OllamaGenerateRequestBuilder withKeepAlive(String keepAlive) {
        this.request.setKeepAlive(keepAlive);
        return this;
    }
}
