Skip to content

Commit 4bb8959

Browse files
committed
Added mistral model
1 parent b13c1bc commit 4bb8959

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { IHttp } from "@rocket.chat/apps-engine/definition/accessors";
2+
3+
import { Prompt } from "../prompt/prompt";
4+
import { ILLMModel } from "./llm.types";
5+
6+
export class Mistral_7B implements ILLMModel {
7+
private http: IHttp;
8+
private readonly model: string = "mistral-7b";
9+
private readonly baseURL: string = "http://mistral-7b/v1";
10+
11+
constructor(http: IHttp) {
12+
this.http = http;
13+
}
14+
15+
async ask(prompt: Prompt): Promise<string | null> {
16+
const url = `${this.baseURL}/chat/completions`;
17+
const res = await this.http.post(url, {
18+
headers: {
19+
"Content-Type": "application/json",
20+
},
21+
data: {
22+
model: this.model,
23+
temprature: 0,
24+
messages: prompt.messages,
25+
},
26+
});
27+
if (!res.content) return null;
28+
29+
const message = JSON.parse(res.content).choices[0].message.content;
30+
return message;
31+
}
32+
}

0 commit comments

Comments
 (0)