Query 🤗TGI /info endpoint to get model name and context window (#755)
* query TGI /info endpoint for model name and context length * remove commented-out line * add parseInt --------- Co-authored-by: Simon Müller <simon.mueller@xitaso.com>
This commit is contained in:
parent
dbbccef8e1
commit
0c77746a91
1 changed files with 19 additions and 0 deletions
|
|
@ -8,6 +8,25 @@ class HuggingFaceTGI extends BaseLLM {
|
|||
apiBase: "http://localhost:8080",
|
||||
};
|
||||
|
||||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
|
||||
this.fetch(`${this.apiBase}/info`, {
|
||||
method: "GET",
|
||||
}).then(async (response) => {
|
||||
if (response.status !== 200) {
|
||||
console.warn(
|
||||
"Error calling Hugging Face TGI /info endpoint: ",
|
||||
await response.text()
|
||||
);
|
||||
return;
|
||||
}
|
||||
const json = await response.json();
|
||||
this.model = json.model_id;
|
||||
this.contextLength = parseInt(json.max_input_length);
|
||||
});
|
||||
}
|
||||
|
||||
private _convertArgs(options: CompletionOptions, prompt: string) {
|
||||
const finalOptions = {
|
||||
max_new_tokens: options.maxTokens,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue