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:
Simon 2024-01-16 18:05:51 +01:00 • committed by GitHub
parent dbbccef8e1
commit 0c77746a91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,