Skip to content

Commit

Permalink
Query 🤗TGI /info endpoint to get model name and context window (#755)
Browse files Browse the repository at this point in the history
* query TGI /info endpoint for model name and context length

* remove commented-out line

* add parseInt

---------

Co-authored-by: Simon Müller <[email protected]>
  • Loading branch information
simon376 and Simon Müller authored Jan 16, 2024
1 parent dbbccef commit 0c77746
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions core/llm/llms/HuggingFaceTGI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0c77746

Please sign in to comment.