add api-key tei embed

This commit is contained in:
YohannZe 2025-03-24 13:27:13 +01:00 • committed by Dallin Romney
parent fd6b3601d1
commit 8c1032bd76

View file

@ -35,14 +35,20 @@ class HuggingFaceTEIEmbeddingsProvider extends BaseLLM {
}
async doEmbedRequest(batch: string[]): Promise<number[][]> {
const headers: Record<string, string> = {
"Content-Type": "application/json",
};
if (this.apiKey) {
headers["Authorization"] = `Bearer ${this.apiKey}`;
}
const resp = await this.fetch(new URL("embed", this.apiBase), {
method: "POST",
body: JSON.stringify({
inputs: batch,
}),
headers: {
"Content-Type": "application/json",
},
headers,
});
if (!resp.ok) {
const text = await resp.text();