mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Requesty models behind api key (#2813)
* Don't fetch Requesty models on startup, only when opening settings * Provide api key when fetching models
This commit is contained in:
parent
f1c3edeb75
commit
b955dbc1fc
2 changed files with 9 additions and 17 deletions
|
|
@ -58,11 +58,17 @@ export class RequestyHandler extends OpenAiHandler {
|
|||
}
|
||||
}
|
||||
|
||||
export async function getRequestyModels() {
|
||||
export async function getRequestyModels(apiKey?: string) {
|
||||
const models: Record<string, ModelInfo> = {}
|
||||
|
||||
try {
|
||||
const response = await axios.get("https://router.requesty.ai/v1/models")
|
||||
const headers: Record<string, string> = {}
|
||||
if (apiKey) {
|
||||
headers["Authorization"] = `Bearer ${apiKey}`
|
||||
}
|
||||
|
||||
const url = "https://router.requesty.ai/v1/models"
|
||||
const response = await axios.get(url, { headers })
|
||||
const rawModels = response.data.data
|
||||
|
||||
for (const rawModel of rawModels) {
|
||||
|
|
|
|||
|
|
@ -152,20 +152,6 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
|
|||
}
|
||||
})
|
||||
|
||||
getRequestyModels().then(async (requestyModels) => {
|
||||
if (Object.keys(requestyModels).length > 0) {
|
||||
await provider.writeModelsToCache(GlobalFileNames.requestyModels, requestyModels)
|
||||
await provider.postMessageToWebview({ type: "requestyModels", requestyModels })
|
||||
|
||||
const { apiConfiguration } = await provider.getState()
|
||||
|
||||
if (apiConfiguration.requestyModelId) {
|
||||
await updateGlobalState("requestyModelInfo", requestyModels[apiConfiguration.requestyModelId])
|
||||
await provider.postStateToWebview()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
provider.providerSettingsManager
|
||||
.listConfig()
|
||||
.then(async (listApiConfig) => {
|
||||
|
|
@ -413,7 +399,7 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
|
|||
|
||||
break
|
||||
case "refreshRequestyModels":
|
||||
const requestyModels = await getRequestyModels()
|
||||
const requestyModels = await getRequestyModels(message.values?.apiKey)
|
||||
|
||||
if (Object.keys(requestyModels).length > 0) {
|
||||
await provider.writeModelsToCache(GlobalFileNames.requestyModels, requestyModels)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue