-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add custom base URL support for Requesty provider #7337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
04cf0c2
29d782f
0bfa63a
a47fcd6
c5e918b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||
| const REQUESTY_BASE_URL = "https://router.requesty.ai/v1" | ||||||
|
|
||||||
| type URLType = "router" | "app" | "api" | ||||||
|
|
||||||
| const replaceCname = (baseUrl: string, type: URLType): string => { | ||||||
| if (type === "router") { | ||||||
| return baseUrl | ||||||
| } else { | ||||||
| return baseUrl.replace("router", type).replace("v1", "") | ||||||
|
||||||
| return baseUrl.replace("router", type).replace("v1", "") | |
| return baseUrl.replace(/\brouter\b/, type).replace(/\/v1\b/, "") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the OAuth path |
||
|
|
||
| return authUrl.toString() | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <VSCodeTextField | ||
|
|
@@ -65,20 +77,30 @@ 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> | ||
| <div className="text-sm text-vscode-descriptionForeground -mt-2"> | ||
| {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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason for changing the parameter order to (baseUrl?, apiKey?) instead of keeping apiKey as the first parameter? Most other provider functions have apiKey as the primary parameter. This could be confusing for consistency.