mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Fix openrouter options
This commit is contained in:
@@ -31,6 +31,7 @@ import { ExtensionMessage } from "../../../../src/shared/ExtensionMessage"
|
|||||||
import { useExtensionState } from "../../context/ExtensionStateContext"
|
import { useExtensionState } from "../../context/ExtensionStateContext"
|
||||||
import { vscode } from "../../utils/vscode"
|
import { vscode } from "../../utils/vscode"
|
||||||
import VSCodeButtonLink from "../common/VSCodeButtonLink"
|
import VSCodeButtonLink from "../common/VSCodeButtonLink"
|
||||||
|
import OpenRouterModelPicker from "./OpenRouterModelPicker"
|
||||||
|
|
||||||
interface ApiOptionsProps {
|
interface ApiOptionsProps {
|
||||||
showModelOptions: boolean
|
showModelOptions: boolean
|
||||||
@@ -529,6 +530,8 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage }: ApiOptionsProps) => {
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{selectedProvider === "openrouter" && showModelOptions && <OpenRouterModelPicker />}
|
||||||
|
|
||||||
{selectedProvider !== "openrouter" &&
|
{selectedProvider !== "openrouter" &&
|
||||||
selectedProvider !== "openai" &&
|
selectedProvider !== "openai" &&
|
||||||
selectedProvider !== "ollama" &&
|
selectedProvider !== "ollama" &&
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { VSCodeDropdown, VSCodeOption } from "@vscode/webview-ui-toolkit/react"
|
|||||||
import React, { useMemo } from "react"
|
import React, { useMemo } from "react"
|
||||||
import { useExtensionState } from "../../context/ExtensionStateContext"
|
import { useExtensionState } from "../../context/ExtensionStateContext"
|
||||||
import { ModelInfoView, normalizeApiConfiguration } from "./ApiOptions"
|
import { ModelInfoView, normalizeApiConfiguration } from "./ApiOptions"
|
||||||
|
import { useMount } from "react-use"
|
||||||
|
import { vscode } from "../../utils/vscode"
|
||||||
|
|
||||||
interface OpenRouterModelPickerProps {}
|
interface OpenRouterModelPickerProps {}
|
||||||
|
|
||||||
@@ -10,14 +12,21 @@ const OpenRouterModelPicker: React.FC<OpenRouterModelPickerProps> = () => {
|
|||||||
|
|
||||||
const handleModelChange = (event: any) => {
|
const handleModelChange = (event: any) => {
|
||||||
const newModelId = event.target.value
|
const newModelId = event.target.value
|
||||||
// get info
|
setApiConfiguration({
|
||||||
setApiConfiguration({ ...apiConfiguration, openRouterModelId: newModelId })
|
...apiConfiguration,
|
||||||
|
openRouterModelId: newModelId,
|
||||||
|
openRouterModelInfo: openRouterModels[newModelId],
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const { selectedModelId, selectedModelInfo } = useMemo(() => {
|
const { selectedModelId, selectedModelInfo } = useMemo(() => {
|
||||||
return normalizeApiConfiguration(apiConfiguration)
|
return normalizeApiConfiguration(apiConfiguration)
|
||||||
}, [apiConfiguration])
|
}, [apiConfiguration])
|
||||||
|
|
||||||
|
useMount(() => {
|
||||||
|
vscode.postMessage({ type: "refreshOpenRouterModels" })
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ display: "flex", flexDirection: "column", gap: 5 }}>
|
<div style={{ display: "flex", flexDirection: "column", gap: 5 }}>
|
||||||
<div className="dropdown-container">
|
<div className="dropdown-container">
|
||||||
|
|||||||
Reference in New Issue
Block a user