-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Adding requesty base url #6992
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
Adding requesty base url #6992
Changes from all commits
baed0b7
f68999e
d2963f8
aa0deea
24bfcd3
c06c491
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 |
|---|---|---|
|
|
@@ -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}`, | ||
| }, | ||
| }) | ||
| }) | ||
|
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. While the test verifies that the custom base URL is passed to the OpenAI constructor, it would be valuable to add a test that actually makes an API call with the custom URL to ensure end-to-end functionality. This could help catch any issues with how the custom URL is used in practice. |
||
|
|
||
| describe("fetchModel", () => { | ||
| it("returns correct model info when options are provided", async () => { | ||
| const handler = new RequestyHandler(mockOptions) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<boolean>() | ||
|
|
||
| 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( | ||
| <K extends keyof ProviderSettings, E>( | ||
| field: K, | ||
|
|
@@ -72,6 +79,31 @@ export const Requesty = ({ | |
| {t("settings:providers.getRequestyApiKey")} | ||
| </VSCodeButtonLink> | ||
| )} | ||
|
|
||
| <VSCodeCheckbox | ||
| checked={requestyEndpointSelected} | ||
| onChange={(e: any) => { | ||
| const isChecked = e.target.checked === true | ||
| if (!isChecked) { | ||
| setApiConfigurationField("requestyBaseUrl", undefined) | ||
|
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 it intentional that unchecking the checkbox immediately clears the base URL value? Users might accidentally uncheck it and lose their custom URL. Consider preserving the value and only clearing it when explicitly deleted by the user, or perhaps add a confirmation dialog?
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 it intentional that unchecking the checkbox immediately clears the base URL value? Users might accidentally uncheck it and lose their custom URL. Consider preserving the value and only clearing it when explicitly deleted by the user, or perhaps add a confirmation dialog? |
||
| } | ||
|
|
||
| setRequestyEndpointSelected(isChecked) | ||
| }}> | ||
| {t("settings:providers.requestyUseCustomBaseUrl")} | ||
| </VSCodeCheckbox> | ||
| {requestyEndpointSelected && ( | ||
| <VSCodeTextField | ||
| value={apiConfiguration?.requestyBaseUrl || ""} | ||
| type="text" | ||
| onInput={handleInputChange("requestyBaseUrl")} | ||
|
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. Consider adding URL validation for the custom base URL input. Currently, any string is accepted which could lead to runtime errors if an invalid URL is provided. You could add validation similar to other providers:
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. Consider adding URL validation for the custom base URL input. Currently, any string is accepted which could lead to runtime errors if an invalid URL is provided. You could add validation similar to other providers to ensure the URL is valid before saving. |
||
| placeholder={t("settings:providers.getRequestyBaseUrl")} | ||
|
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. Consider showing the default URL as a placeholder to guide users. Instead of just the translation key, you could show: This would help users understand the expected format.
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. Consider showing the default URL as a placeholder to guide users. Instead of just the translation key, you could show the default URL (https://router.requesty.ai/v1) to help users understand the expected format. |
||
| className="w-full"> | ||
| <div className="flex justify-between items-center mb-1"> | ||
| <label className="block font-medium">{t("settings:providers.getRequestyBaseUrl")}</label> | ||
| </div> | ||
| </VSCodeTextField> | ||
| )} | ||
| <Button | ||
| variant="outline" | ||
| onClick={() => { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
While the test verifies that the custom base URL is passed to the OpenAI constructor, it would be valuable to add a test that actually makes an API call with the custom URL to ensure end-to-end functionality. This could help catch any issues with how the custom URL is used in practice.