File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,7 +80,8 @@ export interface Config {
8080const DEFAULT_CONFIG : Config = {
8181 provider : "openai" ,
8282 API_KEY : "" ,
83- model : "gpt-4" ,
83+ customEndpoint : "" ,
84+ model : "gpt-4o" ,
8485 templates : {
8586 default : path . join ( os . homedir ( ) , ".lazycommit-template" ) ,
8687 } ,
@@ -283,6 +284,15 @@ async function getModels() {
283284 throw new Error ( "API_KEY is not set" ) ;
284285 }
285286 if ( provider === "openai" ) {
287+ const oai = new OpenAI ( {
288+ apiKey,
289+ } ) ;
290+ const models = await oai . models . list ( ) ;
291+ return models . data . map ( ( model ) => model . id ) ;
292+ } else if ( provider === "custom" ) {
293+ if ( ! config . customEndpoint ) {
294+ throw new Error ( "Custom endpoint is not set" ) ;
295+ }
286296 const oai = new OpenAI ( {
287297 apiKey,
288298 baseURL : config . customEndpoint ,
Original file line number Diff line number Diff line change @@ -104,12 +104,17 @@ export async function run(options: RunOptions, templateName?: string) {
104104 aiProvider = createOpenAI ( {
105105 compatibility : 'strict' ,
106106 apiKey : config . API_KEY ,
107- baseURL : config . customEndpoint ,
108107 } ) ;
109108 } else if ( config . provider === "google" ) {
110109 aiProvider = createGoogleGenerativeAI ( {
111110 apiKey : config . API_KEY ,
112111 } ) ;
112+ } else if ( config . provider === "custom" ) {
113+ aiProvider = createOpenAI ( {
114+ compatibility : 'strict' ,
115+ apiKey : config . API_KEY ,
116+ baseURL : config . customEndpoint
117+ } )
113118 } else {
114119 throw new Error ( "Invalid provider" ) ;
115120 }
You can’t perform that action at this time.
0 commit comments