import { withExponentialBackoff } from "../../util/withExponentialBackoff.js";
import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js";
class DeepInfraEmbeddingsProvider extends BaseEmbeddingsProvider {
    static defaultOptions = {
        model: "sentence-transformers/all-MiniLM-L6-v2",
    };
    get id() {
        return this.options.model ?? "deepinfra";
    }
    async embed(chunks) {
        const fetchWithBackoff = () => withExponentialBackoff(() => this.fetch(`https://api.deepinfra.com/v1/inference/${this.options.model}`, {
            method: "POST",
            headers: {
                Authorization: `bearer ${this.options.apiKey}`,
            },
            body: JSON.stringify({ inputs: chunks }),
        }));
        const resp = await fetchWithBackoff();
        const data = await resp.json();
        return data.embeddings;
    }
}
export default DeepInfraEmbeddingsProvider;
