-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add custom URL option for Requesty provider #6984
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 all commits
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 |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ import type { ModelInfo } from "@roo-code/types" | |
|
|
||
| import { parseApiPrice } from "../../../shared/cost" | ||
|
|
||
| export async function getRequestyModels(apiKey?: string): Promise<Record<string, ModelInfo>> { | ||
| export async function getRequestyModels(apiKey?: string, baseUrl?: string): Promise<Record<string, ModelInfo>> { | ||
| const models: Record<string, ModelInfo> = {} | ||
|
|
||
| try { | ||
|
|
@@ -14,7 +14,8 @@ export async function getRequestyModels(apiKey?: string): Promise<Record<string, | |
| headers["Authorization"] = `Bearer ${apiKey}` | ||
| } | ||
|
|
||
| const url = "https://router.requesty.ai/v1/models" | ||
| const apiBaseUrl = baseUrl || "https://router.requesty.ai/v1" | ||
| const url = `${apiBaseUrl}/models` | ||
|
Contributor
Author
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. Consider normalizing the URL to handle trailing slashes: |
||
| const response = await axios.get(url, { headers }) | ||
| const rawModels = response.data.data | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { useCallback, useState } from "react" | ||
| import { Checkbox } from "vscrui" | ||
| import { VSCodeTextField } from "@vscode/webview-ui-toolkit/react" | ||
|
|
||
| import { type ProviderSettings, type OrganizationAllowList, requestyDefaultModelId } from "@roo-code/types" | ||
|
|
@@ -34,6 +35,7 @@ export const Requesty = ({ | |
| const { t } = useAppTranslation() | ||
|
|
||
| const [didRefetch, setDidRefetch] = useState<boolean>() | ||
| const [requestyBaseUrlSelected, setRequestyBaseUrlSelected] = useState(!!apiConfiguration?.requestyBaseUrl) | ||
|
|
||
| const handleInputChange = useCallback( | ||
| <K extends keyof ProviderSettings, E>( | ||
|
|
@@ -72,6 +74,28 @@ export const Requesty = ({ | |
| {t("settings:providers.getRequestyApiKey")} | ||
| </VSCodeButtonLink> | ||
| )} | ||
| <div> | ||
| <Checkbox | ||
| checked={requestyBaseUrlSelected} | ||
| onChange={(checked: boolean) => { | ||
| setRequestyBaseUrlSelected(checked) | ||
|
|
||
| if (!checked) { | ||
| setApiConfigurationField("requestyBaseUrl", "") | ||
| } | ||
| }}> | ||
| {t("settings:providers.useCustomBaseUrl")} | ||
|
Contributor
Author
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 this intentional? The checkbox label says "Use custom base URL" but it could be more specific like "Use custom Requesty base URL" to match the field naming convention . This would provide better clarity when multiple providers are configured. |
||
| </Checkbox> | ||
| {requestyBaseUrlSelected && ( | ||
| <VSCodeTextField | ||
| value={apiConfiguration?.requestyBaseUrl || ""} | ||
| type="url" | ||
|
Contributor
Author
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. Consider adding URL validation before saving. While provides basic browser validation, you might want to ensure the URL is properly formatted (e.g., starts with http:// or https://) before allowing it to be saved. |
||
| onInput={handleInputChange("requestyBaseUrl")} | ||
| placeholder="Default: https://router.requesty.ai/v1" | ||
| className="w-full mt-1" | ||
| /> | ||
| )} | ||
| </div> | ||
| <Button | ||
| variant="outline" | ||
| onClick={() => { | ||
|
|
||
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.
Good test coverage for the custom base URL! Consider adding edge case tests for: