mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
added configurations for base url api keys
fixed URL construction for models and balance endpoints
This commit is contained in:
parent
5e812cfb4c
commit
f0a5bd68da
4 changed files with 45 additions and 9 deletions
|
|
@ -548,7 +548,14 @@ export const webviewMessageHandler = async (
|
|||
|
||||
const modelFetchPromises: Array<{ key: RouterName; options: GetModelsOptions }> = [
|
||||
{ key: "openrouter", options: { provider: "openrouter" } },
|
||||
{ key: "requesty", options: { provider: "requesty", apiKey: apiConfiguration.requestyApiKey } },
|
||||
{
|
||||
key: "requesty",
|
||||
options: {
|
||||
provider: "requesty",
|
||||
apiKey: apiConfiguration.requestyApiKey,
|
||||
baseUrl: apiConfiguration.requestyBaseUrl,
|
||||
},
|
||||
},
|
||||
{ key: "glama", options: { provider: "glama" } },
|
||||
{ key: "unbound", options: { provider: "unbound", apiKey: apiConfiguration.unboundApiKey } },
|
||||
]
|
||||
|
|
|
|||
|
|
@ -13,5 +13,11 @@ const replaceCname = (baseUrl: string, type: URLType): string => {
|
|||
export const toRequestyServiceUrl = (baseUrl?: string, service: URLType = "router"): string => {
|
||||
let url = replaceCname(baseUrl ?? REQUESTY_BASE_URL, service)
|
||||
|
||||
return new URL(url).toString()
|
||||
try {
|
||||
return new URL(url).toString()
|
||||
} catch (error) {
|
||||
// If the provided baseUrl is invalid, fall back to the default
|
||||
console.warn(`Invalid base URL "${baseUrl}", falling back to default`)
|
||||
return new URL(replaceCname(REQUESTY_BASE_URL, service)).toString()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -419,6 +419,7 @@ const ApiOptions = ({
|
|||
|
||||
{selectedProvider === "requesty" && (
|
||||
<Requesty
|
||||
uriScheme={uriScheme}
|
||||
apiConfiguration={apiConfiguration}
|
||||
setApiConfigurationField={setApiConfigurationField}
|
||||
routerModels={routerModels}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,13 @@ import type { RouterModels } from "@roo/api"
|
|||
|
||||
import { vscode } from "@src/utils/vscode"
|
||||
import { useAppTranslation } from "@src/i18n/TranslationContext"
|
||||
import { VSCodeButtonLink } from "@src/components/common/VSCodeButtonLink"
|
||||
import { Button } from "@src/components/ui"
|
||||
|
||||
import { inputEventTransform } from "../transforms"
|
||||
import { ModelPicker } from "../ModelPicker"
|
||||
import { RequestyBalanceDisplay } from "./RequestyBalanceDisplay"
|
||||
import { getCallbackUrl } from "@/oauth/urls"
|
||||
import { toRequestyServiceUrl } from "@roo/utils/requesty"
|
||||
|
||||
type RequestyProps = {
|
||||
apiConfiguration: ProviderSettings
|
||||
|
|
@ -22,6 +23,7 @@ type RequestyProps = {
|
|||
refetchRouterModels: () => void
|
||||
organizationAllowList: OrganizationAllowList
|
||||
modelValidationError?: string
|
||||
uriScheme?: string
|
||||
}
|
||||
|
||||
export const Requesty = ({
|
||||
|
|
@ -31,6 +33,7 @@ export const Requesty = ({
|
|||
refetchRouterModels,
|
||||
organizationAllowList,
|
||||
modelValidationError,
|
||||
uriScheme,
|
||||
}: RequestyProps) => {
|
||||
const { t } = useAppTranslation()
|
||||
|
||||
|
|
@ -54,6 +57,15 @@ export const Requesty = ({
|
|||
[setApiConfigurationField],
|
||||
)
|
||||
|
||||
const getApiKeyUrl = () => {
|
||||
const callbackUrl = getCallbackUrl("requesty", uriScheme)
|
||||
const baseUrl = toRequestyServiceUrl(apiConfiguration.requestyBaseUrl, "app")
|
||||
|
||||
const authUrl = new URL(`oauth/authorize?callback_url=${callbackUrl}`, baseUrl)
|
||||
|
||||
return authUrl.toString()
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<VSCodeTextField
|
||||
|
|
@ -65,7 +77,10 @@ export const Requesty = ({
|
|||
<div className="flex justify-between items-center mb-1">
|
||||
<label className="block font-medium">{t("settings:providers.requestyApiKey")}</label>
|
||||
{apiConfiguration?.requestyApiKey && (
|
||||
<RequestyBalanceDisplay apiKey={apiConfiguration.requestyApiKey} />
|
||||
<RequestyBalanceDisplay
|
||||
baseUrl={apiConfiguration.requestyBaseUrl}
|
||||
apiKey={apiConfiguration.requestyApiKey}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</VSCodeTextField>
|
||||
|
|
@ -73,12 +88,19 @@ export const Requesty = ({
|
|||
{t("settings:providers.apiKeyStorageNotice")}
|
||||
</div>
|
||||
{!apiConfiguration?.requestyApiKey && (
|
||||
<VSCodeButtonLink
|
||||
href="https://app.requesty.ai/api-keys"
|
||||
style={{ width: "100%" }}
|
||||
appearance="primary">
|
||||
<a
|
||||
href={getApiKeyUrl()}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center justify-center whitespace-nowrap text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground shadow hover:bg-primary/90 h-9 rounded-md px-3 w-full"
|
||||
style={{
|
||||
width: "100%",
|
||||
textDecoration: "none",
|
||||
color: "var(--vscode-button-foreground)",
|
||||
backgroundColor: "var(--vscode-button-background)",
|
||||
}}>
|
||||
{t("settings:providers.getRequestyApiKey")}
|
||||
</VSCodeButtonLink>
|
||||
</a>
|
||||
)}
|
||||
|
||||
<VSCodeCheckbox
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue