add api-key tei embed
This commit is contained in:
parent
fd6b3601d1
commit
8c1032bd76
1 changed files with 9 additions and 3 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue