import type winston from 'winston';
import type { EnvOverrides } from './env';
import type { Prompt } from './prompts';
import type { NunjucksFilterMap, TokenUsage } from './shared';
export type { TokenUsage } from './shared';
export type ProviderId = string;
export type ProviderLabel = string;
export type ProviderFunction = ApiProvider['callApi'];
export type ProviderOptionsMap = Record<ProviderId, ProviderOptions>;
export type ProviderType = 'embedding' | 'classification' | 'text' | 'moderation' | 'audio';
export type ProviderTypeMap = Partial<Record<ProviderType, string | ProviderOptions | ApiProvider>>;
interface AtomicTestCase {
    description?: string;
    vars?: Record<string, string | object>;
    providerResponse?: ProviderResponse;
    tokenUsage?: TokenUsage;
    success?: boolean;
    score?: number;
    failureReason?: string;
    metadata?: Record<string, any>;
    options?: Record<string, any>;
}
export interface ProviderModerationResponse {
    error?: string;
    flags?: ModerationFlag[];
}
export interface ModerationFlag {
    code: string;
    description: string;
    confidence: number;
}
export interface ProviderOptions {
    applicationId?: string;
    id?: ProviderId;
    label?: ProviderLabel;
    config?: any;
    prompts?: string[];
    transform?: string;
    delay?: number;
    env?: EnvOverrides;
    language?: string;
    type?: string;
    enableEncryption?: string;
    workspaceId?: string;
}
export interface CallApiContextParams {
    filters?: NunjucksFilterMap;
    getCache?: any;
    logger?: winston.Logger;
    originalProvider?: ApiProvider;
    prompt: Prompt;
    vars: Record<string, string | object>;
    debug?: boolean;
    test?: AtomicTestCase;
    aiSpeaksFirst?: boolean;
    bustCache?: boolean;
    traceparent?: string;
    tracestate?: string;
    evaluationId?: string;
    testCaseId?: string;
    repeatIndex?: number;
    fetchWithCache?: any;
    _conversation?: any;
}
export interface CallApiOptionsParams {
    includeLogProbs?: boolean;
    /**
     * Signal that can be used to abort the request
     */
    abortSignal?: AbortSignal;
}
export interface ApiProvider {
    applicationId?: string | (() => string);
    id: () => string;
    callApi: CallApiFunction;
    callClassificationApi?: (prompt: string) => Promise<ProviderClassificationResponse>;
    callEmbeddingApi?: (input: string) => Promise<ProviderEmbeddingResponse>;
    config?: any;
    delay?: number;
    getSessionId?: () => string;
    label?: ProviderLabel;
    transform?: string;
    toJSON?: () => any;
    language?: string;
    type?: string;
    /**
     * Cleanup method called when a provider call is aborted (e.g., due to timeout)
     * Providers should implement this to clean up any resources they might have
     * allocated, such as file handles, network connections, etc.
     */
    cleanup?: () => void | Promise<void>;
    enableEncryption?: string;
}
export interface ApiEmbeddingProvider extends ApiProvider {
    callEmbeddingApi: (input: string) => Promise<ProviderEmbeddingResponse>;
}
export interface ApiSimilarityProvider extends ApiProvider {
    callSimilarityApi: (reference: string, input: string) => Promise<ProviderSimilarityResponse>;
}
export interface ApiClassificationProvider extends ApiProvider {
    callClassificationApi: (prompt: string) => Promise<ProviderClassificationResponse>;
}
export interface ApiModerationProvider extends ApiProvider {
    callModerationApi: (prompt: string, response: string) => Promise<ProviderModerationResponse>;
}
export interface GuardrailResponse {
    flaggedInput?: boolean;
    flaggedOutput?: boolean;
    flagged?: boolean;
    reason?: string;
}
export interface ProviderResponse {
    cached?: boolean;
    cost?: number;
    error?: string;
    logProbs?: number[];
    latencyMs?: number;
    metadata?: {
        redteamFinalPrompt?: string;
        http?: {
            status: number;
            statusText: string;
            headers: Record<string, string>;
            requestHeaders?: Record<string, string>;
        };
        [key: string]: any;
    };
    raw?: string | any;
    output?: string | any;
    anonymized_output?: string | any;
    /**
     * Output after provider-level transform. Used by contextTransform to ensure
     * it operates on provider-normalized output, independent of test transforms.
     */
    providerTransformedOutput?: string | any;
    tokenUsage?: TokenUsage;
    isRefusal?: boolean;
    sessionId?: string;
    guardrails?: GuardrailResponse;
    finishReason?: string;
    outputAudio?: string | any;
    audio?: {
        id?: string;
        expiresAt?: number;
        data?: string;
        transcript?: string;
        format?: string;
    };
    video?: {
        id?: string;
        expiresAt?: number;
        data?: string;
        url?: string;
        caption?: string;
        format?: string;
    };
}
export interface ProviderEmbeddingResponse {
    cost?: number;
    error?: string;
    embedding?: number[];
    latencyMs?: number;
    tokenUsage?: Partial<TokenUsage>;
    metadata?: {
        transformed?: boolean;
        originalText?: string;
        [key: string]: any;
    };
}
export interface ProviderSimilarityResponse {
    error?: string;
    similarity?: number;
    tokenUsage?: Partial<TokenUsage>;
}
export interface ProviderClassificationResponse {
    error?: string;
    classification?: Record<string, number>;
}
export type FilePath = string;
export type CallApiFunction = {
    (prompt: string, context?: CallApiContextParams, options?: CallApiOptionsParams): Promise<ProviderResponse>;
    label?: string;
};
export declare function isApiProvider(provider: any): provider is ApiProvider;
export declare function isProviderOptions(provider: any): provider is ProviderOptions;
export interface ProviderTestResponse {
    testResult: {
        message?: string;
        error?: string;
        changes_needed?: boolean;
        changes_needed_reason?: string;
        changes_needed_suggestions?: string[];
    };
    providerResponse: ProviderResponse;
    unalignedProviderResult?: ProviderResponse;
    redteamProviderResult?: ProviderResponse;
    transformedRequest?: any;
}
/**
 * Interface defining the default providers used by the application
 */
export interface DefaultProviders {
    embeddingProvider: ApiProvider;
    gradingJsonProvider: ApiProvider;
    gradingProvider: ApiProvider;
    llmRubricProvider?: ApiProvider;
    moderationProvider: ApiProvider;
    suggestionsProvider: ApiProvider;
    synthesizeProvider: ApiProvider;
    webSearchProvider?: ApiProvider;
    audioProvider: ApiProvider;
    sttProvider: ApiProvider;
    videoProvider: ApiProvider;
    hallucinationProvider: ApiProvider;
}
//# sourceMappingURL=providers.d.ts.map