"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultProviders = void 0;
const logger_1 = __importDefault(require("../logger"));
const anthropic_1 = require("./anthropic");
const openai_1 = require("./openai");
const vertex_1 = require("./vertex");
const vertexUtil_1 = require("./vertexUtil");
async function getDefaultProviders(env) {
    const preferAnthropic = !process.env.OPENAI_API_KEY &&
        !env?.OPENAI_API_KEY &&
        (process.env.ANTHROPIC_API_KEY || env?.ANTHROPIC_API_KEY);
    if (preferAnthropic) {
        logger_1.default.debug('Using Anthropic default providers');
        return {
            embeddingProvider: openai_1.DefaultEmbeddingProvider, // TODO(ian): Voyager instead?
            gradingProvider: anthropic_1.DefaultGradingProvider,
            gradingJsonProvider: anthropic_1.DefaultGradingJsonProvider,
            suggestionsProvider: anthropic_1.DefaultSuggestionsProvider,
            moderationProvider: openai_1.DefaultModerationProvider,
        };
    }
    const preferGoogle = !process.env.OPENAI_API_KEY && !env?.OPENAI_API_KEY && (await (0, vertexUtil_1.hasGoogleDefaultCredentials)());
    if (preferGoogle) {
        logger_1.default.debug('Using Google default providers');
        return {
            embeddingProvider: vertex_1.DefaultEmbeddingProvider,
            gradingProvider: vertex_1.DefaultGradingProvider,
            gradingJsonProvider: vertex_1.DefaultGradingProvider,
            suggestionsProvider: vertex_1.DefaultGradingProvider,
            moderationProvider: openai_1.DefaultModerationProvider,
        };
    }
    logger_1.default.debug('Using OpenAI default providers');
    return {
        embeddingProvider: openai_1.DefaultEmbeddingProvider,
        gradingProvider: openai_1.DefaultGradingProvider,
        gradingJsonProvider: openai_1.DefaultGradingJsonProvider,
        suggestionsProvider: openai_1.DefaultSuggestionsProvider,
        moderationProvider: openai_1.DefaultModerationProvider,
    };
}
exports.getDefaultProviders = getDefaultProviders;
//# sourceMappingURL=defaults.js.map