@@ -62,14 +62,14 @@ function hasOwn<T extends object, K extends PropertyKey>(
6262export const configPath = path . join ( os . homedir ( ) , ".lazycommit" ) ;
6363
6464export interface Config {
65- provider : "openai" | "google" ;
65+ provider : "openai" | "google" ;
6666 API_KEY : string ;
6767 model : string ;
6868 templates : Record < string , string > ;
6969}
7070
7171const DEFAULT_CONFIG : Config = {
72- provider : "openai" ,
72+ provider : "openai" ,
7373 API_KEY : "" ,
7474 model : "gpt-4o" ,
7575 templates : {
@@ -135,11 +135,11 @@ export async function showConfigUI() {
135135 const choice = ( await p . select ( {
136136 message : "set config" ,
137137 options : [
138- {
139- label : "Provider" ,
140- value : "provider" ,
141- hint : config . provider ,
142- } ,
138+ {
139+ label : "Provider" ,
140+ value : "provider" ,
141+ hint : config . provider ,
142+ } ,
143143 {
144144 label : "API Key" ,
145145 value : "API_KEY" ,
@@ -166,7 +166,7 @@ export async function showConfigUI() {
166166 } ) ) as keyof Config | "template" | "cancel" | symbol ;
167167
168168 if ( p . isCancel ( choice ) ) {
169- process . exit ( 0 ) ;
169+ process . exit ( 0 ) ;
170170 }
171171
172172 if ( choice === "API_KEY" ) {
@@ -227,29 +227,29 @@ export async function showConfigUI() {
227227 await editFile ( templatePath , ( ) => {
228228 console . log ( `Prompt template '${ templateChoice } ' updated` ) ;
229229 } ) ;
230- process . exit ( 0 ) ;
230+ process . exit ( 0 ) ;
231231 }
232232 } else if ( choice === "provider" ) {
233- const provider = await p . select ( {
234- message : "Provider" ,
235- options : [
236- {
237- label : "OpenAI" ,
238- value : "openai" ,
239- } ,
240- {
241- label : "Google" ,
242- value : "google" ,
243- } ,
244- ] ,
245- initialValue : config . provider ,
246- } ) ;
247-
248- await setConfigs ( [ [ "provider" , provider as string ] ] ) ;
249- }
233+ const provider = await p . select ( {
234+ message : "Provider" ,
235+ options : [
236+ {
237+ label : "OpenAI" ,
238+ value : "openai" ,
239+ } ,
240+ {
241+ label : "Google" ,
242+ value : "google" ,
243+ } ,
244+ ] ,
245+ initialValue : config . provider ,
246+ } ) ;
247+
248+ await setConfigs ( [ [ "provider" , provider as string ] ] ) ;
249+ }
250250
251251 if ( p . isCancel ( choice ) ) {
252- process . exit ( 0 ) ;
252+ process . exit ( 0 ) ;
253253 }
254254
255255 showConfigUI ( ) ;
@@ -260,23 +260,23 @@ export async function showConfigUI() {
260260}
261261
262262async function getModels ( ) {
263- const config = await readConfigFile ( ) ;
264- const provider = config . provider ;
265- const apiKey = config . API_KEY ;
266- if ( ! apiKey ) {
267- throw new Error ( "API_KEY is not set" ) ;
268- }
269- if ( provider === "openai" ) {
270-
271- const oai = new OpenAI ( {
272- apiKey,
273- } ) ;
274-
275- const models = await oai . models . list ( ) ;
276- return models . data . map ( ( model ) => model . id ) ;
277- } else if ( provider === "google" ) {
278- return [ "gemini-1.5-flash" , "gemini-1.5-pro" ] ;
279- } else {
280- throw new Error ( "Invalid provider" ) ;
281- }
263+ const config = await readConfigFile ( ) ;
264+ const provider = config . provider ;
265+ const apiKey = config . API_KEY ;
266+ if ( ! apiKey ) {
267+ throw new Error ( "API_KEY is not set" ) ;
268+ }
269+ if ( provider === "openai" ) {
270+
271+ const oai = new OpenAI ( {
272+ apiKey,
273+ } ) ;
274+
275+ const models = await oai . models . list ( ) ;
276+ return models . data . map ( ( model ) => model . id ) ;
277+ } else if ( provider === "google" ) {
278+ return [ "gemini-1.5-flash" , "gemini-1.5-pro" , "gemini-1.5-pro-002" , "gemini-1.5-flash-8b" , "gemini-1.5-flash-002 "] ;
279+ } else {
280+ throw new Error ( "Invalid provider" ) ;
281+ }
282282}
0 commit comments