import { HfInference } from "@huggingface/inference";
import type { PreTrainedModel, PreTrainedTokenizer } from "@xenova/transformers";
import { BaseLLM } from "./base.js";
import type { ChatResponse, ChatResponseChunk, LLMChatParamsNonStreaming, LLMChatParamsStreaming, LLMMetadata } from "./types.js";
interface HfInferenceOptions {
    /**
     * (Default: true) Boolean. If a request 503s and wait_for_model is set to false, the request will be retried with the same parameters but with wait_for_model set to true.
     */
    retry_on_error?: boolean;
    /**
     * (Default: true). Boolean. There is a cache layer on Inference API (serverless) to speedup requests we have already seen. Most models can use those results as is as models are deterministic (meaning the results will be the same anyway). However if you use a non deterministic model, you can set this parameter to prevent the caching mechanism from being used resulting in a real new query.
     */
    use_cache?: boolean;
    /**
     * (Default: false). Boolean. Do not load the model if it's not already available.
     */
    dont_load_model?: boolean;
    /**
     * (Default: false). Boolean to use GPU instead of CPU for inference (requires Startup plan at least).
     */
    use_gpu?: boolean;
    /**
     * (Default: false) Boolean. If the model is not ready, wait for it instead of receiving 503. It limits the number of requests required to get your inference done. It is advised to only set this flag to true after receiving a 503 error as it will limit hanging in your application to known places.
     */
    wait_for_model?: boolean;
    /**
     * Custom fetch function to use instead of the default one, for example to use a proxy or edit headers.
     */
    fetch?: typeof fetch;
    /**
     * Abort Controller signal to use for request interruption.
     */
    signal?: AbortSignal;
    /**
     * (Default: "same-origin"). String | Boolean. Credentials to use for the request. If this is a string, it will be passed straight on. If it's a boolean, true will be "include" and false will not send credentials at all.
     */
    includeCredentials?: string | boolean;
}
declare const DEFAULT_PARAMS: {
    temperature: number;
    topP: number;
    maxTokens: undefined;
    contextWindow: number;
};
export type HFConfig = Partial<typeof DEFAULT_PARAMS> & HfInferenceOptions & {
    model: string;
    accessToken: string;
    endpoint?: string;
};
/**
    Wrapper on the Hugging Face's Inference API.
    API Docs: https://huggingface.co/docs/huggingface.js/inference/README
    List of tasks with models: huggingface.co/api/tasks
    
    Note that Conversational API is not yet supported by the Inference API.
    They recommend using the text generation API instead.
    See: https://github.com/huggingface/huggingface.js/issues/586#issuecomment-2024059308
 */
export declare class HuggingFaceInferenceAPI extends BaseLLM {
    model: string;
    temperature: number;
    topP: number;
    maxTokens?: number;
    contextWindow: number;
    hf: HfInference;
    constructor(init: HFConfig);
    get metadata(): LLMMetadata;
    chat(params: LLMChatParamsStreaming): Promise<AsyncIterable<ChatResponseChunk>>;
    chat(params: LLMChatParamsNonStreaming): Promise<ChatResponse>;
    private messagesToPrompt;
    protected nonStreamChat(params: LLMChatParamsNonStreaming): Promise<ChatResponse>;
    protected streamChat(params: LLMChatParamsStreaming): AsyncIterable<ChatResponseChunk>;
}
export interface HFLLMConfig {
    modelName?: string;
    tokenizerName?: string;
    temperature?: number;
    topP?: number;
    maxTokens?: number;
    contextWindow?: number;
}
export declare class HuggingFaceLLM extends BaseLLM {
    modelName: string;
    tokenizerName: string;
    temperature: number;
    topP: number;
    maxTokens?: number;
    contextWindow: number;
    private tokenizer;
    private model;
    constructor(init?: HFLLMConfig);
    get metadata(): LLMMetadata;
    getTokenizer(): Promise<PreTrainedTokenizer>;
    getModel(): Promise<PreTrainedModel>;
    chat(params: LLMChatParamsStreaming): Promise<AsyncIterable<ChatResponseChunk>>;
    chat(params: LLMChatParamsNonStreaming): Promise<ChatResponse>;
    protected nonStreamChat(params: LLMChatParamsNonStreaming): Promise<ChatResponse>;
    protected streamChat(params: LLMChatParamsStreaming): AsyncIterable<ChatResponseChunk>;
}
export {};
