| 7 | interface FlowiseAiConfig extends AiEngineConfig {} |
| 8 | |
| 9 | export class FlowiseEngine implements AiEngine { |
| 10 | config: FlowiseAiConfig; |
| 11 | client: AxiosInstance; |
| 12 | |
| 13 | constructor(config) { |
| 14 | this.config = config; |
| 15 | this.client = axios.create({ |
| 16 | url: `${config.baseURL}/${config.apiKey}`, |
| 17 | headers: { 'Content-Type': 'application/json' } |
| 18 | }); |
| 19 | } |
| 20 | |
| 21 | async generateCommitMessage( |
| 22 | messages: Array<OpenAI.Chat.Completions.ChatCompletionMessageParam> |
| 23 | ): Promise<string | undefined> { |
| 24 | const gitDiff = (messages[messages.length - 1]?.content as string) |
| 25 | .replace(/\\/g, '\\\\') |
| 26 | .replace(/"/g, '\\"') |
| 27 | .replace(/\n/g, '\\n') |
| 28 | .replace(/\r/g, '\\r') |
| 29 | .replace(/\t/g, '\\t'); |
| 30 | |
| 31 | const payload = { |
| 32 | question: gitDiff, |
| 33 | overrideConfig: { |
| 34 | systemMessagePrompt: messages[0]?.content |
| 35 | }, |
| 36 | history: messages.slice(1, -1) |
| 37 | }; |
| 38 | try { |
| 39 | const response = await this.client.post('', payload); |
| 40 | const message = response.data; |
| 41 | let content = message?.text; |
| 42 | return removeContentTags(content, 'think'); |
| 43 | } catch (error) { |
| 44 | throw normalizeEngineError(error, 'flowise', this.config.model); |
| 45 | } |
| 46 | } |
| 47 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…