Elffuss BraidHub

kikocis/continue public

71fd2e7d4456 · 976 BRawPermalink
1import { LLMOptions } from "../../index.js";
2
3import OpenAI from "./OpenAI.js";
4
5class Vllm extends OpenAI {
6 static providerName = "vllm";
7 constructor(options: LLMOptions) {
8 super(options);
9
10 if (options.model === "AUTODETECT") {
11 this._setupCompletionOptions();
12 }
13 }
14
15 private _setupCompletionOptions() {
16 this.fetch(this._getEndpoint("models"), {
17 method: "GET",
18 headers: this._getHeaders(),
19 })
20 .then(async (response) => {
21 if (response.status !== 200) {
22 console.warn(
23 "Error calling vLLM /models endpoint: ",
24 await response.text(),
25 );
26 return;
27 }
28 const json = await response.json();
29 const data = json.data[0];
30 this.model = data.id;
31 this.contextLength = Number.parseInt(data.max_model_len);
32 })
33 .catch((e) => {
34 console.log(`Failed to list models for vLLM: ${e.message}`);
35 });
36 }
37}
38
39export default Vllm;