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

Class AimlApiEngine

src/engine/aimlapi.ts:8–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6interface AimlApiConfig extends AiEngineConfig {}
7
8export class AimlApiEngine implements AiEngine {
9 client: AxiosInstance;
10
11 constructor(public config: AimlApiConfig) {
12 this.client = axios.create({
13 baseURL: config.baseURL || 'https://api.aimlapi.com/v1/chat/completions',
14 headers: {
15 Authorization: `Bearer ${config.apiKey}`,
16 'HTTP-Referer': 'https://github.com/di-sukharev/opencommit',
17 'X-Title': 'opencommit',
18 'Content-Type': 'application/json',
19 ...config.customHeaders
20 }
21 });
22 }
23
24 public generateCommitMessage = async (
25 messages: Array<OpenAI.Chat.Completions.ChatCompletionMessageParam>
26 ): Promise<string | null> => {
27 try {
28 const response = await this.client.post('', {
29 model: this.config.model,
30 messages
31 });
32
33 const message = response.data.choices?.[0]?.message;
34 return message?.content ?? null;
35 } catch (error) {
36 throw normalizeEngineError(error, 'aimlapi', this.config.model);
37 }
38 };
39}

Callers

nothing calls this directly

Calls 2

normalizeEngineErrorFunction · 0.90
postMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…