Elffuss BraidHub

kikocis/continue public

d691089ac9f7 · 1.0 KiBRawPermalink
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 supportsFim(): boolean {
16 return false;
17 }
18
19 private _setupCompletionOptions() {
20 this.fetch(this._getEndpoint("models"), {
21 method: "GET",
22 headers: this._getHeaders(),
23 })
24 .then(async (response) => {
25 if (response.status !== 200) {
26 console.warn(
27 "Error calling vLLM /models endpoint: ",
28 await response.text(),
29 );
30 return;
31 }
32 const json = await response.json();
33 const data = json.data[0];
34 this.model = data.id;
35 this.contextLength = Number.parseInt(data.max_model_len);
36 })
37 .catch((e) => {
38 console.log(`Failed to list models for vLLM: ${e.message}`);
39 });
40 }
41}
42
43export default Vllm;