Merge pull request #2804 from cblh/feat/tei-reranker-api-key
feat: add API key support for TEI reranker
This commit is contained in:
commit
dc65e0850f
3 changed files with 14 additions and 1 deletions
|
|
@ -15,6 +15,7 @@ export class HuggingFaceTEIReranker implements Reranker {
|
|||
apiBase?: string;
|
||||
truncate?: boolean;
|
||||
truncation_direction?: string;
|
||||
apiKey?: string;
|
||||
},
|
||||
) {}
|
||||
|
||||
|
|
@ -24,9 +25,17 @@ export class HuggingFaceTEIReranker implements Reranker {
|
|||
apiBase += "/";
|
||||
}
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
|
||||
if (this.params.apiKey) {
|
||||
headers["Authorization"] = `Bearer ${this.params.apiKey}`;
|
||||
}
|
||||
|
||||
const resp = await fetch(new URL("rerank", apiBase), {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
query: query,
|
||||
return_text: false,
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ The `"modelTitle"` field must match one of the models in your "models" array in
|
|||
"name": "huggingface-tei",
|
||||
"params": {
|
||||
"apiBase": "http://localhost:8080",
|
||||
"apiKey": "<TEI_API_KEY>",
|
||||
"truncate": true,
|
||||
"truncation_direction": "Right"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2637,6 +2637,9 @@
|
|||
"type": "string",
|
||||
"default": "http://localhost:8080"
|
||||
},
|
||||
"apiKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"truncate": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to truncate long sequences to the maximum allowed context length.",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue