From fff534022c018789cab88b1d59ad3e460e35d81c Mon Sep 17 00:00:00 2001 From: YohannZe <99359799+YohannZe@users.noreply.github.com> Date: Mon, 24 Mar 2025 13:27:13 +0100 Subject: [PATCH 1/2] add api-key tei embed --- core/llm/llms/HuggingFaceTEI.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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(); From 9ee71904f2631278403b601e28139f8ed337e92f Mon Sep 17 00:00:00 2001 From: YohannZe <99359799+YohannZe@users.noreply.github.com> Date: Mon, 24 Mar 2025 13:38:20 +0100 Subject: [PATCH 2/2] update docs tei with apikey --- docs/docs/customize/model-roles/embeddings.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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": "" } } ```