import { LanguageModelV1, ProviderV1, EmbeddingModelV1 } from '@ai-sdk/provider';

type OllamaChatModelId = 'codegemma' | 'codegemma:2b' | 'codegemma:7b' | 'codellama' | 'codellama:7b' | 'codellama:13b' | 'codellama:34b' | 'codellama:70b' | 'codellama:code' | 'codellama:python' | 'command-r' | 'command-r:35b' | 'command-r-plus' | 'command-r-plus:104b' | 'deepseek-coder-v2' | 'deepseek-coder-v2:16b' | 'deepseek-coder-v2:236b' | 'falcon2' | 'falcon2:11b' | 'firefunction-v2' | 'firefunction-v2:70b' | 'gemma' | 'gemma:2b' | 'gemma:7b' | 'gemma2' | 'gemma2:2b' | 'gemma2:9b' | 'gemma2:27b' | 'llama2' | 'llama2:7b' | 'llama2:13b' | 'llama2:70b' | 'llama3' | 'llama3:8b' | 'llama3:70b' | 'llama3-chatqa' | 'llama3-chatqa:8b' | 'llama3-chatqa:70b' | 'llama3-gradient' | 'llama3-gradient:8b' | 'llama3-gradient:70b' | 'llama3.1' | 'llama3.1:8b' | 'llama3.1:70b' | 'llama3.1:405b' | 'llava' | 'llava:7b' | 'llava:13b' | 'llava:34b' | 'llava-llama3' | 'llava-llama3:8b' | 'llava-phi3' | 'llava-phi3:3.8b' | 'mistral' | 'mistral:7b' | 'mistral-large' | 'mistral-large:123b' | 'mistral-nemo' | 'mistral-nemo:12b' | 'mixtral' | 'mixtral:8x7b' | 'mixtral:8x22b' | 'moondream' | 'moondream:1.8b' | 'openhermes' | 'openhermes:v2.5' | 'phi3' | 'phi3:3.8b' | 'phi3:14b' | 'phi3.5' | 'phi3.5:3.8b' | 'qwen' | 'qwen:7b' | 'qwen:14b' | 'qwen:32b' | 'qwen:72b' | 'qwen:110b' | 'qwen2' | 'qwen2:0.5b' | 'qwen2:1.5b' | 'qwen2:7b' | 'qwen2:72b' | 'smollm' | 'smollm:135m' | 'smollm:360m' | 'smollm:1.7b' | (string & NonNullable<unknown>);
interface OllamaChatSettings {
    /**
     * Until Ollama officially supports tool calling in streams, the provider can try to detect function calls. Enabled by
     * default to maintain backward compatibility, disable it if you encounter any issues.
     */
    experimentalStreamTools?: boolean;
    /**
     * Enable Mirostat sampling for controlling perplexity. (default: 0, 0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0)
     */
    mirostat?: 0 | 1 | 2;
    /**
     * Influences how quickly the algorithm responds to feedback from the generated text. A lower learning rate will
     * result in slower adjustments, while a higher learning rate will make the algorithm more responsive. (Default: 0.1)
     */
    mirostatEta?: number;
    /**
     * Controls the balance between coherence and diversity of the output. A lower value will result in more focused and
     * coherent text. (Default: 5.0)
     */
    mirostatTau?: number;
    /**
     * Sets the size of the context window used to generate the next token. (Default: 2048)
     */
    numCtx?: number;
    /**
     * Sets how far back for the model to look back to prevent repetition. (Default: 64, 0 = disabled, -1 = num_ctx)
     */
    repeatLastN?: number;
    /**
     * Sets how strongly to penalize repetitions. A higher value (e.g., 1.5) will penalize repetitions more strongly
     * , while a lower value (e.g., 0.9) will be more lenient. (Default: 1.1)
     */
    repeatPenalty?: number;
    /**
     * Sets the stop sequences to use. When this pattern is encountered the LLM will stop generating text and return.
     * Multiple stop patterns may be set by specifying multiple separate `stop` parameters in a modelfile.
     *
     * @deprecated Use `stopSequences` from AI SDK functions.
     */
    stop?: string;
    /**
     * Tail free sampling is used to reduce the impact of less probable tokens from the output. A higher value (e.g., 2.0)
     * will reduce the impact more, while a value of 1.0 disables this setting. (default: 1)
     */
    tfsZ?: number;
    /**
     * Reduces the probability of generating nonsense. A higher value (e.g. 100) will give more diverse answers, while a
     * lower value (e.g. 10) will be more conservative. (Default: 40)
     *
     * @deprecated Use `topK` from AI SDK functions.
     */
    topK?: number;
}

interface OllamaChatConfig {
    baseURL: string;
    fetch?: typeof fetch;
    headers: () => Record<string, string | undefined>;
    provider: string;
}
declare class OllamaChatLanguageModel implements LanguageModelV1 {
    readonly modelId: OllamaChatModelId;
    readonly settings: OllamaChatSettings;
    readonly config: OllamaChatConfig;
    readonly specificationVersion = "v1";
    readonly defaultObjectGenerationMode = "json";
    readonly supportsImageUrls = false;
    constructor(modelId: OllamaChatModelId, settings: OllamaChatSettings, config: OllamaChatConfig);
    get provider(): string;
    private getArguments;
    doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
    doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
}

type OllamaEmbeddingModelId = 'all-minilm' | 'all-minilm:22m' | 'all-minilm:33m' | 'bge-large' | 'bge-m3' | 'mxbai-embed-large' | 'nomic-embed-text' | 'paraphrase-multilingual' | 'snowflake-arctic-embed' | 'snowflake-arctic-embed:110m' | 'snowflake-arctic-embed:137m' | 'snowflake-arctic-embed:22m' | 'snowflake-arctic-embed:335m' | 'snowflake-arctic-embed:33m' | OllamaChatModelId | (string & NonNullable<unknown>);
interface OllamaEmbeddingSettings {
    maxEmbeddingsPerCall?: number;
    truncate?: boolean;
}

interface OllamaProvider extends ProviderV1 {
    (modelId: OllamaChatModelId, settings?: OllamaChatSettings): LanguageModelV1;
    chat(modelId: OllamaChatModelId, settings?: OllamaChatSettings): LanguageModelV1;
    /**
     * @deprecated Use `textEmbeddingModel` instead.
     */
    embedding(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV1<string>;
    languageModel(modelId: OllamaChatModelId, settings?: OllamaChatSettings): LanguageModelV1;
    /**
     * @deprecated Use `textEmbeddingModel()` instead.
     */
    textEmbedding(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV1<string>;
    textEmbeddingModel(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV1<string>;
}
interface OllamaProviderSettings {
    /**
     * Base URL for Ollama API calls.
     */
    baseURL?: string;
    /**
     * Custom fetch implementation. You can use it as a middleware to intercept
     * requests or to provide a custom fetch implementation for e.g. testing
     */
    fetch?: typeof fetch;
    /**
     * Custom headers to include in the requests.
     */
    headers?: Record<string, string>;
}
declare function createOllama(options?: OllamaProviderSettings): OllamaProvider;
declare const ollama: OllamaProvider;

declare class Ollama {
    readonly baseURL: string;
    readonly headers?: Record<string, string>;
    constructor(options?: OllamaProviderSettings);
    private get baseConfig();
    chat(modelId: OllamaChatModelId, settings?: OllamaChatSettings): OllamaChatLanguageModel;
}

export { Ollama, type OllamaProvider, type OllamaProviderSettings, createOllama, ollama };
