File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
ai-assistant/src/core/llm Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments