Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ApiKey to TEI embedding provider #4783

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions core/llm/llms/HuggingFaceTEI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion docs/docs/customize/model-roles/embeddings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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: <YOUR_TEI_API_KEY>
roles: [embed]
```
</TabItem>
Expand All @@ -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": "<YOUR_TEI_API_KEY>"
}
}
```
Expand Down
Loading