From baed0b72a03f7f719342fc283b968461c1604ac8 Mon Sep 17 00:00:00 2001 From: John Costa Date: Tue, 12 Aug 2025 11:09:46 +0100 Subject: [PATCH 1/6] adding option to have a custom requesty URL adding locales fix fix fix --- packages/types/src/provider-settings.ts | 1 + src/api/providers/__tests__/requesty.spec.ts | 15 ++++++++ src/api/providers/requesty.ts | 2 +- .../settings/providers/Requesty.tsx | 36 +++++++++++++++++-- webview-ui/src/i18n/locales/ca/settings.json | 2 ++ webview-ui/src/i18n/locales/de/settings.json | 2 ++ webview-ui/src/i18n/locales/en/settings.json | 2 ++ webview-ui/src/i18n/locales/es/settings.json | 2 ++ webview-ui/src/i18n/locales/fr/settings.json | 2 ++ webview-ui/src/i18n/locales/hi/settings.json | 2 ++ webview-ui/src/i18n/locales/id/settings.json | 2 ++ webview-ui/src/i18n/locales/it/settings.json | 2 ++ webview-ui/src/i18n/locales/ja/settings.json | 2 ++ webview-ui/src/i18n/locales/ko/settings.json | 2 ++ webview-ui/src/i18n/locales/nl/settings.json | 2 ++ .../src/i18n/locales/pt-BR/settings.json | 2 ++ webview-ui/src/i18n/locales/ru/settings.json | 2 ++ webview-ui/src/i18n/locales/tr/settings.json | 2 ++ webview-ui/src/i18n/locales/vi/settings.json | 2 ++ .../src/i18n/locales/zh-CN/settings.json | 2 ++ .../src/i18n/locales/zh-TW/settings.json | 2 ++ 21 files changed, 85 insertions(+), 3 deletions(-) diff --git a/packages/types/src/provider-settings.ts b/packages/types/src/provider-settings.ts index e6b5c4ca26..fe04ad9185 100644 --- a/packages/types/src/provider-settings.ts +++ b/packages/types/src/provider-settings.ts @@ -225,6 +225,7 @@ const unboundSchema = baseProviderSettingsSchema.extend({ }) const requestySchema = baseProviderSettingsSchema.extend({ + requestyBaseUrl: z.string().optional(), requestyApiKey: z.string().optional(), requestyModelId: z.string().optional(), }) diff --git a/src/api/providers/__tests__/requesty.spec.ts b/src/api/providers/__tests__/requesty.spec.ts index 55fb976fd1..72d4aa790b 100644 --- a/src/api/providers/__tests__/requesty.spec.ts +++ b/src/api/providers/__tests__/requesty.spec.ts @@ -65,6 +65,21 @@ describe("RequestyHandler", () => { }) }) + it("can use a base URL instead of the default", () => { + const handler = new RequestyHandler({ ...mockOptions, requestyBaseUrl: "some-base-url" }) + expect(handler).toBeInstanceOf(RequestyHandler) + + expect(OpenAI).toHaveBeenCalledWith({ + baseURL: "some-base-url", + apiKey: mockOptions.requestyApiKey, + defaultHeaders: { + "HTTP-Referer": "https://github.com/RooVetGit/Roo-Cline", + "X-Title": "Roo Code", + "User-Agent": `RooCode/${Package.version}`, + }, + }) + }) + describe("fetchModel", () => { it("returns correct model info when options are provided", async () => { const handler = new RequestyHandler(mockOptions) diff --git a/src/api/providers/requesty.ts b/src/api/providers/requesty.ts index d2e55fc8f0..771c695961 100644 --- a/src/api/providers/requesty.ts +++ b/src/api/providers/requesty.ts @@ -47,7 +47,7 @@ export class RequestyHandler extends BaseProvider implements SingleCompletionHan this.options = options this.client = new OpenAI({ - baseURL: "https://router.requesty.ai/v1", + baseURL: options.requestyBaseUrl || "https://router.requesty.ai/v1", apiKey: this.options.requestyApiKey ?? "not-provided", defaultHeaders: DEFAULT_HEADERS, }) diff --git a/webview-ui/src/components/settings/providers/Requesty.tsx b/webview-ui/src/components/settings/providers/Requesty.tsx index ac9e2735e9..dace21e851 100644 --- a/webview-ui/src/components/settings/providers/Requesty.tsx +++ b/webview-ui/src/components/settings/providers/Requesty.tsx @@ -1,5 +1,5 @@ -import { useCallback, useState } from "react" -import { VSCodeTextField } from "@vscode/webview-ui-toolkit/react" +import { useCallback, useEffect, useState } from "react" +import { VSCodeCheckbox, VSCodeTextField } from "@vscode/webview-ui-toolkit/react" import { type ProviderSettings, type OrganizationAllowList, requestyDefaultModelId } from "@roo-code/types" @@ -35,6 +35,13 @@ export const Requesty = ({ const [didRefetch, setDidRefetch] = useState() + const [requestyEndpointSelected, setRequestyEndpointSelected] = useState(!!apiConfiguration.requestyBaseUrl) + + // This ensures that the "Use custom URL" checkbox is hidden when the user deletes the URL. + useEffect(() => { + setRequestyEndpointSelected(!!apiConfiguration?.requestyBaseUrl) + }, [apiConfiguration?.requestyBaseUrl]) + const handleInputChange = useCallback( ( field: K, @@ -72,6 +79,31 @@ export const Requesty = ({ {t("settings:providers.getRequestyApiKey")} )} + + { + const isChecked = e.target.checked === true + if (!isChecked) { + setApiConfigurationField("requestyBaseUrl", undefined) + } + + setRequestyEndpointSelected(isChecked) + }}> + {t("settings:providers.requestyUseCustomBaseUrl")} + + {requestyEndpointSelected && ( + +
+ +
+
+ )}