diff --git a/core/llm/llms/HuggingFaceTEI.ts b/core/llm/llms/HuggingFaceTEI.ts index 52580c1878..187db8122b 100644 --- a/core/llm/llms/HuggingFaceTEI.ts +++ b/core/llm/llms/HuggingFaceTEI.ts @@ -35,14 +35,20 @@ class HuggingFaceTEIEmbeddingsProvider extends BaseLLM { } async doEmbedRequest(batch: string[]): Promise { + const headers: Record = { + "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(); diff --git a/docs/docs/customize/model-roles/embeddings.mdx b/docs/docs/customize/model-roles/embeddings.mdx index a58cd520d0..ce5357792b 100644 --- a/docs/docs/customize/model-roles/embeddings.mdx +++ b/docs/docs/customize/model-roles/embeddings.mdx @@ -100,6 +100,7 @@ See [here](../model-providers/top-level/ollama.mdx#embeddings-model) for instruc - name: Huggingface TEI Embedder provider: huggingface-tei apiBase: http://localhost:8080 + apiKey: roles: [embed] ``` @@ -108,7 +109,8 @@ See [here](../model-providers/top-level/ollama.mdx#embeddings-model) for instruc { "embeddingsProvider": { "provider": "huggingface-tei", - "apiBase": "http://localhost:8080" + "apiBase": "http://localhost:8080", + "apiKey": "" } } ```