Skip to content

Commit 3acb3ba

Browse files
mrubensellipsis-dev[bot]requesty-JohnCosta27roomote-agent
authored
Adding requesty base url (#6992)
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: John Costa <[email protected]> Co-authored-by: Roo Code <[email protected]>
1 parent 2730ef9 commit 3acb3ba

File tree

22 files changed

+87
-3
lines changed

22 files changed

+87
-3
lines changed

packages/types/src/provider-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ const unboundSchema = baseProviderSettingsSchema.extend({
225225
})
226226

227227
const requestySchema = baseProviderSettingsSchema.extend({
228+
requestyBaseUrl: z.string().optional(),
228229
requestyApiKey: z.string().optional(),
229230
requestyModelId: z.string().optional(),
230231
})

src/api/providers/__tests__/requesty.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ describe("RequestyHandler", () => {
6565
})
6666
})
6767

68+
it("can use a base URL instead of the default", () => {
69+
const handler = new RequestyHandler({ ...mockOptions, requestyBaseUrl: "some-base-url" })
70+
expect(handler).toBeInstanceOf(RequestyHandler)
71+
72+
expect(OpenAI).toHaveBeenCalledWith({
73+
baseURL: "some-base-url",
74+
apiKey: mockOptions.requestyApiKey,
75+
defaultHeaders: {
76+
"HTTP-Referer": "https://github.com/RooVetGit/Roo-Cline",
77+
"X-Title": "Roo Code",
78+
"User-Agent": `RooCode/${Package.version}`,
79+
},
80+
})
81+
})
82+
6883
describe("fetchModel", () => {
6984
it("returns correct model info when options are provided", async () => {
7085
const handler = new RequestyHandler(mockOptions)

src/api/providers/requesty.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class RequestyHandler extends BaseProvider implements SingleCompletionHan
4747
this.options = options
4848

4949
this.client = new OpenAI({
50-
baseURL: "https://router.requesty.ai/v1",
50+
baseURL: options.requestyBaseUrl || "https://router.requesty.ai/v1",
5151
apiKey: this.options.requestyApiKey ?? "not-provided",
5252
defaultHeaders: DEFAULT_HEADERS,
5353
})

webview-ui/src/components/settings/providers/Requesty.tsx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useCallback, useState } from "react"
2-
import { VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
1+
import { useCallback, useEffect, useState } from "react"
2+
import { VSCodeCheckbox, VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
33

44
import { type ProviderSettings, type OrganizationAllowList, requestyDefaultModelId } from "@roo-code/types"
55

@@ -35,6 +35,13 @@ export const Requesty = ({
3535

3636
const [didRefetch, setDidRefetch] = useState<boolean>()
3737

38+
const [requestyEndpointSelected, setRequestyEndpointSelected] = useState(!!apiConfiguration.requestyBaseUrl)
39+
40+
// This ensures that the "Use custom URL" checkbox is hidden when the user deletes the URL.
41+
useEffect(() => {
42+
setRequestyEndpointSelected(!!apiConfiguration?.requestyBaseUrl)
43+
}, [apiConfiguration?.requestyBaseUrl])
44+
3845
const handleInputChange = useCallback(
3946
<K extends keyof ProviderSettings, E>(
4047
field: K,
@@ -72,6 +79,31 @@ export const Requesty = ({
7279
{t("settings:providers.getRequestyApiKey")}
7380
</VSCodeButtonLink>
7481
)}
82+
83+
<VSCodeCheckbox
84+
checked={requestyEndpointSelected}
85+
onChange={(e: any) => {
86+
const isChecked = e.target.checked === true
87+
if (!isChecked) {
88+
setApiConfigurationField("requestyBaseUrl", undefined)
89+
}
90+
91+
setRequestyEndpointSelected(isChecked)
92+
}}>
93+
{t("settings:providers.requestyUseCustomBaseUrl")}
94+
</VSCodeCheckbox>
95+
{requestyEndpointSelected && (
96+
<VSCodeTextField
97+
value={apiConfiguration?.requestyBaseUrl || ""}
98+
type="text"
99+
onInput={handleInputChange("requestyBaseUrl")}
100+
placeholder={t("settings:providers.getRequestyBaseUrl")}
101+
className="w-full">
102+
<div className="flex justify-between items-center mb-1">
103+
<label className="block font-medium">{t("settings:providers.getRequestyBaseUrl")}</label>
104+
</div>
105+
</VSCodeTextField>
106+
)}
75107
<Button
76108
variant="outline"
77109
onClick={() => {

webview-ui/src/i18n/locales/ca/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/de/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@
252252
"error": "Failed to refresh models list. Please try again."
253253
},
254254
"getRequestyApiKey": "Get Requesty API Key",
255+
"getRequestyBaseUrl": "Base URL",
256+
"requestyUseCustomBaseUrl": "Use custom base URL",
255257
"openRouterTransformsText": "Compress prompts and message chains to the context size (<a>OpenRouter Transforms</a>)",
256258
"anthropicApiKey": "Anthropic API Key",
257259
"getAnthropicApiKey": "Get Anthropic API Key",

webview-ui/src/i18n/locales/es/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/fr/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/hi/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)