mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-14 23:21:19 +00:00
DRYs up read model from cache logic
This commit is contained in:
parent
a8f764983f
commit
c049436101
1 changed files with 10 additions and 21 deletions
|
|
@ -1775,16 +1775,20 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||
// await this.postMessageToWebview({ type: "action", action: "settingsButtonClicked" }) // bad ux if user is on welcome
|
||||
}
|
||||
|
||||
async readGlamaModels(): Promise<Record<string, ModelInfo> | undefined> {
|
||||
const glamaModelsFilePath = path.join(await this.ensureCacheDirectoryExists(), GlobalFileNames.glamaModels)
|
||||
const fileExists = await fileExistsAtPath(glamaModelsFilePath)
|
||||
private async readModelsFromCache(filename: string): Promise<Record<string, ModelInfo> | undefined> {
|
||||
const filePath = path.join(await this.ensureCacheDirectoryExists(), filename)
|
||||
const fileExists = await fileExistsAtPath(filePath)
|
||||
if (fileExists) {
|
||||
const fileContents = await fs.readFile(glamaModelsFilePath, "utf8")
|
||||
const fileContents = await fs.readFile(filePath, "utf8")
|
||||
return JSON.parse(fileContents)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
async readGlamaModels(): Promise<Record<string, ModelInfo> | undefined> {
|
||||
return this.readModelsFromCache(GlobalFileNames.glamaModels)
|
||||
}
|
||||
|
||||
async refreshGlamaModels() {
|
||||
const glamaModelsFilePath = path.join(await this.ensureCacheDirectoryExists(), GlobalFileNames.glamaModels)
|
||||
|
||||
|
|
@ -1860,16 +1864,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||
}
|
||||
|
||||
async readOpenRouterModels(): Promise<Record<string, ModelInfo> | undefined> {
|
||||
const openRouterModelsFilePath = path.join(
|
||||
await this.ensureCacheDirectoryExists(),
|
||||
GlobalFileNames.openRouterModels,
|
||||
)
|
||||
const fileExists = await fileExistsAtPath(openRouterModelsFilePath)
|
||||
if (fileExists) {
|
||||
const fileContents = await fs.readFile(openRouterModelsFilePath, "utf8")
|
||||
return JSON.parse(fileContents)
|
||||
}
|
||||
return undefined
|
||||
return this.readModelsFromCache(GlobalFileNames.openRouterModels)
|
||||
}
|
||||
|
||||
async refreshOpenRouterModels() {
|
||||
|
|
@ -1985,13 +1980,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||
}
|
||||
|
||||
async readUnboundModels(): Promise<Record<string, ModelInfo> | undefined> {
|
||||
const unboundModelsFilePath = path.join(await this.ensureCacheDirectoryExists(), GlobalFileNames.unboundModels)
|
||||
const fileExists = await fileExistsAtPath(unboundModelsFilePath)
|
||||
if (fileExists) {
|
||||
const fileContents = await fs.readFile(unboundModelsFilePath, "utf8")
|
||||
return JSON.parse(fileContents)
|
||||
}
|
||||
return undefined
|
||||
return this.readModelsFromCache(GlobalFileNames.unboundModels)
|
||||
}
|
||||
|
||||
async refreshUnboundModels() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue