MCPcopy
hub / github.com/di-sukharev/opencommit / MLXEngine

Class MLXEngine

src/engine/mlx.ts:12–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10const MLX_CHAT_PATH = '/v1/chat/completions';
11
12export class MLXEngine implements AiEngine {
13 config: MLXConfig;
14 client: AxiosInstance;
15 private chatUrl: string;
16
17 constructor(config) {
18 this.config = config;
19
20 const baseUrl = config.baseURL || DEFAULT_MLX_URL;
21 this.chatUrl = `${baseUrl}${MLX_CHAT_PATH}`;
22
23 this.client = axios.create({
24 headers: { 'Content-Type': 'application/json' }
25 });
26 }
27
28 async generateCommitMessage(
29 messages: Array<OpenAI.Chat.Completions.ChatCompletionMessageParam>
30 ): Promise<string | undefined> {
31 const params = {
32 messages,
33 temperature: 0,
34 top_p: 0.1,
35 repetition_penalty: 1.5,
36 stream: false
37 };
38 try {
39 const response = await this.client.post(this.chatUrl, params);
40
41 const choices = response.data.choices;
42 const message = choices[0].message;
43 let content = message?.content;
44 return removeContentTags(content, 'think');
45 } catch (error) {
46 throw normalizeEngineError(error, 'mlx', this.config.model);
47 }
48 }
49}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…