@@ -33,7 +33,9 @@ export enum CONFIG_KEYS {
33
33
OCO_AZURE_ENDPOINT = 'OCO_AZURE_ENDPOINT' ,
34
34
OCO_TEST_MOCK_TYPE = 'OCO_TEST_MOCK_TYPE' ,
35
35
OCO_API_URL = 'OCO_API_URL' ,
36
- OCO_OLLAMA_API_URL = 'OCO_OLLAMA_API_URL'
36
+ OCO_OLLAMA_API_URL = 'OCO_OLLAMA_API_URL' ,
37
+ OCO_FLOWISE_ENDPOINT = 'OCO_FLOWISE_ENDPOINT' ,
38
+ OCO_FLOWISE_API_KEY = 'OCO_FLOWISE_API_KEY'
37
39
}
38
40
39
41
export enum CONFIG_MODES {
@@ -130,7 +132,8 @@ export const configValidators = {
130
132
config . OCO_ANTHROPIC_API_KEY ||
131
133
config . OCO_AI_PROVIDER . startsWith ( 'ollama' ) ||
132
134
config . OCO_AZURE_API_KEY ||
133
- config . OCO_AI_PROVIDER == 'test' ,
135
+ config . OCO_AI_PROVIDER == 'test' ||
136
+ config . OCO_AI_PROVIDER == 'flowise' ,
134
137
'You need to provide an OpenAI/Anthropic/Azure API key'
135
138
) ;
136
139
validateConfig (
@@ -149,7 +152,8 @@ export const configValidators = {
149
152
config . OCO_OPENAI_API_KEY ||
150
153
config . OCO_AZURE_API_KEY ||
151
154
config . OCO_AI_PROVIDER == 'ollama' ||
152
- config . OCO_AI_PROVIDER == 'test' ,
155
+ config . OCO_AI_PROVIDER == 'test' ||
156
+ config . OCO_AI_PROVIDER == 'flowise' ,
153
157
'You need to provide an OpenAI/Anthropic/Azure API key'
154
158
) ;
155
159
@@ -175,13 +179,24 @@ export const configValidators = {
175
179
value ||
176
180
config . OCO_OPENAI_API_KEY ||
177
181
config . OCO_AI_PROVIDER == 'ollama' ||
178
- config . OCO_AI_PROVIDER == 'test' ,
182
+ config . OCO_AI_PROVIDER == 'test' ||
183
+ config . OCO_AI_PROVIDER == 'flowise' ,
179
184
'You need to provide an OpenAI/Anthropic API key'
180
185
) ;
181
186
182
187
return value ;
183
188
} ,
184
189
190
+ [ CONFIG_KEYS . OCO_FLOWISE_API_KEY ] ( value : any , config : any = { } ) {
191
+ validateConfig (
192
+ CONFIG_KEYS . OCO_FLOWISE_API_KEY ,
193
+ value || config . OCO_AI_PROVIDER != 'flowise' ,
194
+ 'You need to provide a flowise API key'
195
+ ) ;
196
+
197
+ return value ;
198
+ } ,
199
+
185
200
[ CONFIG_KEYS . OCO_DESCRIPTION ] ( value : any ) {
186
201
validateConfig (
187
202
CONFIG_KEYS . OCO_DESCRIPTION ,
@@ -268,7 +283,8 @@ export const configValidators = {
268
283
] . includes ( value ) ||
269
284
config . OCO_AI_PROVIDER == 'ollama' ||
270
285
config . OCO_AI_PROVIDER == 'azure' ||
271
- config . OCO_AI_PROVIDER == 'test' ,
286
+ config . OCO_AI_PROVIDER == 'test' ||
287
+ config . OCO_AI_PROVIDER == 'flowise' ,
272
288
`${ value } is not supported yet, use:\n\n ${ [
273
289
...MODEL_LIST . openai ,
274
290
...MODEL_LIST . anthropic ,
@@ -308,9 +324,16 @@ export const configValidators = {
308
324
[ CONFIG_KEYS . OCO_AI_PROVIDER ] ( value : any ) {
309
325
validateConfig (
310
326
CONFIG_KEYS . OCO_AI_PROVIDER ,
311
- [ '' , 'openai' , 'anthropic' , 'gemini' , 'azure' , 'test' ] . includes ( value ) ||
312
- value . startsWith ( 'ollama' ) ,
313
- `${ value } is not supported yet, use 'ollama', 'anthropic', 'azure', 'gemini' or 'openai' (default)`
327
+ [
328
+ '' ,
329
+ 'openai' ,
330
+ 'anthropic' ,
331
+ 'gemini' ,
332
+ 'azure' ,
333
+ 'test' ,
334
+ 'flowise'
335
+ ] . includes ( value ) || value . startsWith ( 'ollama' ) ,
336
+ `${ value } is not supported yet, use 'ollama', 'anthropic', 'azure', 'gemini', 'flowise' or 'openai' (default)`
314
337
) ;
315
338
return value ;
316
339
} ,
@@ -324,6 +347,7 @@ export const configValidators = {
324
347
325
348
return value ;
326
349
} ,
350
+
327
351
[ CONFIG_KEYS . OCO_AZURE_ENDPOINT ] ( value : any ) {
328
352
validateConfig (
329
353
CONFIG_KEYS . OCO_AZURE_ENDPOINT ,
@@ -333,6 +357,17 @@ export const configValidators = {
333
357
334
358
return value ;
335
359
} ,
360
+
361
+ [ CONFIG_KEYS . OCO_FLOWISE_ENDPOINT ] ( value : any ) {
362
+ validateConfig (
363
+ CONFIG_KEYS . OCO_FLOWISE_ENDPOINT ,
364
+ typeof value === 'string' && value . includes ( ':' ) ,
365
+ 'Value must be string and should include both I.P. and port number' // Considering the possibility of DNS lookup or feeding the I.P. explicitely, there is no pattern to verify, except a column for the port number
366
+ ) ;
367
+
368
+ return value ;
369
+ } ,
370
+
336
371
[ CONFIG_KEYS . OCO_TEST_MOCK_TYPE ] ( value : any ) {
337
372
validateConfig (
338
373
CONFIG_KEYS . OCO_TEST_MOCK_TYPE ,
@@ -361,7 +396,6 @@ export type ConfigType = {
361
396
362
397
const defaultConfigPath = pathJoin ( homedir ( ) , '.opencommit' ) ;
363
398
const defaultEnvPath = pathResolve ( process . cwd ( ) , '.env' ) ;
364
-
365
399
export const getConfig = ( {
366
400
configPath = defaultConfigPath ,
367
401
envPath = defaultEnvPath
@@ -397,9 +431,10 @@ export const getConfig = ({
397
431
process . env . OCO_ONE_LINE_COMMIT === 'true' ? true : false ,
398
432
OCO_AZURE_ENDPOINT : process . env . OCO_AZURE_ENDPOINT || undefined ,
399
433
OCO_TEST_MOCK_TYPE : process . env . OCO_TEST_MOCK_TYPE || 'commit-message' ,
400
- OCO_OLLAMA_API_URL : process . env . OCO_OLLAMA_API_URL || undefined ,
434
+ OCO_FLOWISE_ENDPOINT : process . env . OCO_FLOWISE_ENDPOINT || ':' ,
435
+ OCO_FLOWISE_API_KEY : process . env . OCO_FLOWISE_API_KEY || undefined ,
436
+ OCO_OLLAMA_API_URL : process . env . OCO_OLLAMA_API_URL || undefined
401
437
} ;
402
-
403
438
const configExists = existsSync ( configPath ) ;
404
439
if ( ! configExists ) return configFromEnv ;
405
440
0 commit comments