Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/api/providers/requesty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 1 addition & 15 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)
Expand Down