@@ -1775,16 +1775,20 @@ export class ClineProvider implements vscode.WebviewViewProvider {
17751775 // await this.postMessageToWebview({ type: "action", action: "settingsButtonClicked" }) // bad ux if user is on welcome
17761776 }
17771777
1778- async readGlamaModels ( ) : Promise < Record < string , ModelInfo > | undefined > {
1779- const glamaModelsFilePath = path . join ( await this . ensureCacheDirectoryExists ( ) , GlobalFileNames . glamaModels )
1780- const fileExists = await fileExistsAtPath ( glamaModelsFilePath )
1778+ private async readModelsFromCache ( filename : string ) : Promise < Record < string , ModelInfo > | undefined > {
1779+ const filePath = path . join ( await this . ensureCacheDirectoryExists ( ) , filename )
1780+ const fileExists = await fileExistsAtPath ( filePath )
17811781 if ( fileExists ) {
1782- const fileContents = await fs . readFile ( glamaModelsFilePath , "utf8" )
1782+ const fileContents = await fs . readFile ( filePath , "utf8" )
17831783 return JSON . parse ( fileContents )
17841784 }
17851785 return undefined
17861786 }
17871787
1788+ async readGlamaModels ( ) : Promise < Record < string , ModelInfo > | undefined > {
1789+ return this . readModelsFromCache ( GlobalFileNames . glamaModels )
1790+ }
1791+
17881792 async refreshGlamaModels ( ) {
17891793 const glamaModelsFilePath = path . join ( await this . ensureCacheDirectoryExists ( ) , GlobalFileNames . glamaModels )
17901794
@@ -1860,16 +1864,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
18601864 }
18611865
18621866 async readOpenRouterModels ( ) : Promise < Record < string , ModelInfo > | undefined > {
1863- const openRouterModelsFilePath = path . join (
1864- await this . ensureCacheDirectoryExists ( ) ,
1865- GlobalFileNames . openRouterModels ,
1866- )
1867- const fileExists = await fileExistsAtPath ( openRouterModelsFilePath )
1868- if ( fileExists ) {
1869- const fileContents = await fs . readFile ( openRouterModelsFilePath , "utf8" )
1870- return JSON . parse ( fileContents )
1871- }
1872- return undefined
1867+ return this . readModelsFromCache ( GlobalFileNames . openRouterModels )
18731868 }
18741869
18751870 async refreshOpenRouterModels ( ) {
@@ -1985,13 +1980,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
19851980 }
19861981
19871982 async readUnboundModels ( ) : Promise < Record < string , ModelInfo > | undefined > {
1988- const unboundModelsFilePath = path . join ( await this . ensureCacheDirectoryExists ( ) , GlobalFileNames . unboundModels )
1989- const fileExists = await fileExistsAtPath ( unboundModelsFilePath )
1990- if ( fileExists ) {
1991- const fileContents = await fs . readFile ( unboundModelsFilePath , "utf8" )
1992- return JSON . parse ( fileContents )
1993- }
1994- return undefined
1983+ return this . readModelsFromCache ( GlobalFileNames . unboundModels )
19951984 }
19961985
19971986 async refreshUnboundModels ( ) {
0 commit comments