Skip to content

Commit f97f3e4

Browse files
committed
Move sort routing option
1 parent f47be1a commit f97f3e4

File tree

2 files changed

+54
-48
lines changed

2 files changed

+54
-48
lines changed

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import { useExtensionState } from "../../context/ExtensionStateContext"
5151
import { vscode } from "../../utils/vscode"
5252
import { getAsVar, VSC_DESCRIPTION_FOREGROUND } from "../../utils/vscStyles"
5353
import VSCodeButtonLink from "../common/VSCodeButtonLink"
54-
import OpenRouterModelPicker, { ModelDescriptionMarkdown } from "./OpenRouterModelPicker"
54+
import OpenRouterModelPicker, { ModelDescriptionMarkdown, OPENROUTER_MODEL_PICKER_Z_INDEX } from "./OpenRouterModelPicker"
5555
import { ClineAccountInfoCard } from "./ClineAccountInfoCard"
5656

5757
interface ApiOptionsProps {
@@ -95,6 +95,7 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is
9595
const [awsEndpointSelected, setAwsEndpointSelected] = useState(!!apiConfiguration?.awsBedrockEndpoint)
9696
const [modelConfigurationSelected, setModelConfigurationSelected] = useState(false)
9797
const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false)
98+
const [providerSortingSelected, setProviderSortingSelected] = useState(!!apiConfiguration?.openRouterProviderSorting)
9899

99100
const handleInputChange = (field: keyof ApiConfiguration) => (event: any) => {
100101
setApiConfiguration({
@@ -1353,6 +1354,57 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is
13531354
</p>
13541355
)}
13551356

1357+
{(selectedProvider === "openrouter" || selectedProvider === "cline") && showModelOptions && (
1358+
<>
1359+
<VSCodeCheckbox
1360+
style={{ marginTop: -10 }}
1361+
checked={providerSortingSelected}
1362+
onChange={(e: any) => {
1363+
const isChecked = e.target.checked === true
1364+
setProviderSortingSelected(isChecked)
1365+
if (!isChecked) {
1366+
setApiConfiguration({
1367+
...apiConfiguration,
1368+
openRouterProviderSorting: "",
1369+
})
1370+
}
1371+
}}>
1372+
Sort underlying provider routing
1373+
</VSCodeCheckbox>
1374+
1375+
{providerSortingSelected && (
1376+
<div style={{ marginBottom: -6 }}>
1377+
<DropdownContainer className="dropdown-container" zIndex={OPENROUTER_MODEL_PICKER_Z_INDEX - 3}>
1378+
<VSCodeDropdown
1379+
style={{ width: "100%", marginTop: 3 }}
1380+
value={apiConfiguration?.openRouterProviderSorting}
1381+
onChange={(e: any) => {
1382+
setApiConfiguration({
1383+
...apiConfiguration,
1384+
openRouterProviderSorting: e.target.value,
1385+
})
1386+
}}>
1387+
<VSCodeOption value="">Default</VSCodeOption>
1388+
<VSCodeOption value="price">Price</VSCodeOption>
1389+
<VSCodeOption value="throughput">Throughput</VSCodeOption>
1390+
<VSCodeOption value="latency">Latency</VSCodeOption>
1391+
</VSCodeDropdown>
1392+
</DropdownContainer>
1393+
<p style={{ fontSize: "12px", marginTop: 3, color: "var(--vscode-descriptionForeground)" }}>
1394+
{!apiConfiguration?.openRouterProviderSorting &&
1395+
"Default behavior is to load balance requests across providers (like AWS, Google Vertex, Anthropic), prioritizing price while considering provider uptime"}
1396+
{apiConfiguration?.openRouterProviderSorting === "price" &&
1397+
"Sort providers by price, prioritizing the lowest cost provider"}
1398+
{apiConfiguration?.openRouterProviderSorting === "throughput" &&
1399+
"Sort providers by throughput, prioritizing the provider with the highest throughput (may increase cost)"}
1400+
{apiConfiguration?.openRouterProviderSorting === "latency" &&
1401+
"Sort providers by response time, prioritizing the provider with the lowest latency"}
1402+
</p>
1403+
</div>
1404+
)}
1405+
</>
1406+
)}
1407+
13561408
{selectedProvider !== "openrouter" &&
13571409
selectedProvider !== "cline" &&
13581410
selectedProvider !== "openai" &&

webview-ui/src/components/settings/OpenRouterModelPicker.tsx

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const OpenRouterModelPicker: React.FC<OpenRouterModelPickerProps> = ({ isPopup }
2525
const itemRefs = useRef<(HTMLDivElement | null)[]>([])
2626
const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false)
2727
const dropdownListRef = useRef<HTMLDivElement>(null)
28-
const [providerSortingSelected, setProviderSortingSelected] = useState(!!apiConfiguration?.openRouterProviderSorting)
2928

3029
const handleModelChange = (newModelId: string) => {
3130
// could be setting invalid model id/undefined info but validation will catch it
@@ -223,52 +222,7 @@ const OpenRouterModelPicker: React.FC<OpenRouterModelPickerProps> = ({ isPopup }
223222
{showBudgetSlider && (
224223
<ThinkingBudgetSlider apiConfiguration={apiConfiguration} setApiConfiguration={setApiConfiguration} />
225224
)}
226-
<VSCodeCheckbox
227-
style={{ marginTop: 3 }}
228-
checked={providerSortingSelected}
229-
onChange={(e: any) => {
230-
const isChecked = e.target.checked === true
231-
setProviderSortingSelected(isChecked)
232-
if (!isChecked) {
233-
setApiConfiguration({
234-
...apiConfiguration,
235-
openRouterProviderSorting: "",
236-
})
237-
}
238-
}}>
239-
Sort underlying provider routing
240-
</VSCodeCheckbox>
241-
242-
{providerSortingSelected && (
243-
<div style={{ marginBottom: -6 }}>
244-
<DropdownContainer className="dropdown-container" zIndex={OPENROUTER_MODEL_PICKER_Z_INDEX - 3}>
245-
<VSCodeDropdown
246-
style={{ width: "100%", marginTop: 3 }}
247-
value={apiConfiguration?.openRouterProviderSorting}
248-
onChange={(e: any) => {
249-
setApiConfiguration({
250-
...apiConfiguration,
251-
openRouterProviderSorting: e.target.value,
252-
})
253-
}}>
254-
<VSCodeOption value="">Default</VSCodeOption>
255-
<VSCodeOption value="price">Price</VSCodeOption>
256-
<VSCodeOption value="throughput">Throughput</VSCodeOption>
257-
<VSCodeOption value="latency">Latency</VSCodeOption>
258-
</VSCodeDropdown>
259-
</DropdownContainer>
260-
<p style={{ fontSize: "12px", marginTop: 3, color: "var(--vscode-descriptionForeground)" }}>
261-
{!apiConfiguration?.openRouterProviderSorting &&
262-
"Default behavior is to load balance requests across providers (like AWS, Google Vertex, Anthropic), prioritizing price while considering provider uptime"}
263-
{apiConfiguration?.openRouterProviderSorting === "price" &&
264-
"Sort providers by price, prioritizing the lowest cost provider"}
265-
{apiConfiguration?.openRouterProviderSorting === "throughput" &&
266-
"Sort providers by throughput, prioritizing the provider with the highest throughput (may increase cost)"}
267-
{apiConfiguration?.openRouterProviderSorting === "latency" &&
268-
"Sort providers by response time, prioritizing the provider with the lowest latency"}
269-
</p>
270-
</div>
271-
)}
225+
272226
<ModelInfoView
273227
selectedModelId={selectedModelId}
274228
modelInfo={selectedModelInfo}

0 commit comments

Comments
 (0)