import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
class OpenAIEmbeddingProvider {
  dimension;
  apiKey;
  model;
  constructor(apiKey, model, dimension) {
    this.apiKey = apiKey;
    this.model = model;
    this.dimension = dimension;
  }
  async embed(text) {
    const res = await fetch("https://api.openai.com/v1/embeddings", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${this.apiKey}`
      },
      body: JSON.stringify({ model: this.model, input: text })
    });
    if (!res.ok) throw new Error(`OpenAI embed failed: ${res.status}`);
    const data = await res.json();
    return data.data[0].embedding;
  }
  async embedBatch(texts) {
    const res = await fetch("https://api.openai.com/v1/embeddings", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${this.apiKey}`
      },
      body: JSON.stringify({ model: this.model, input: texts })
    });
    if (!res.ok) throw new Error(`OpenAI embed batch failed: ${res.status}`);
    const data = await res.json();
    return data.data.map((d) => d.embedding);
  }
}
export {
  OpenAIEmbeddingProvider
};
//# sourceMappingURL=openai-embedding-provider.js.map
