From 58bc32948193e6b329189ab547ab0b037b17cd05 Mon Sep 17 00:00:00 2001 From: RaySinner <118297374+RaySinner@users.noreply.github.com> Date: Wed, 8 Jan 2025 10:36:14 +0300 Subject: [PATCH] refactor: update API options and remove unused type definitions --- src/types/vscode.d.ts | 86 ------------------- .../src/components/settings/ApiOptions.tsx | 3 +- webview-ui/src/types/vscode.d.ts | 8 -- 3 files changed, 2 insertions(+), 95 deletions(-) delete mode 100644 src/types/vscode.d.ts delete mode 100644 webview-ui/src/types/vscode.d.ts diff --git a/src/types/vscode.d.ts b/src/types/vscode.d.ts deleted file mode 100644 index 1b4c402..0000000 --- a/src/types/vscode.d.ts +++ /dev/null @@ -1,86 +0,0 @@ -declare namespace vscode { - enum LanguageModelChatMessageRole { - User = 1, - Assistant = 2 - } - - enum LanguageModelChatToolMode { - Auto = 1, - Required = 2 - } - - interface LanguageModelChatSelector { - vendor?: string; - family?: string; - version?: string; - id?: string; - } - - interface LanguageModelChatTool { - name: string; - description: string; - inputSchema?: object; - } - - interface LanguageModelChatRequestOptions { - justification?: string; - modelOptions?: { [name: string]: any; }; - tools?: LanguageModelChatTool[]; - toolMode?: LanguageModelChatToolMode; - } - - class LanguageModelTextPart { - value: string; - constructor(value: string); - } - - class LanguageModelToolCallPart { - callId: string; - name: string; - input: object; - constructor(callId: string, name: string, input: object); - } - - interface LanguageModelChatResponse { - stream: AsyncIterable; - text: AsyncIterable; - } - - interface LanguageModelChat { - readonly name: string; - readonly id: string; - readonly vendor: string; - readonly family: string; - readonly version: string; - readonly maxInputTokens: number; - - sendRequest(messages: LanguageModelChatMessage[], options?: LanguageModelChatRequestOptions, token?: CancellationToken): Thenable; - countTokens(text: string | LanguageModelChatMessage, token?: CancellationToken): Thenable; - } - - class LanguageModelPromptTsxPart { - value: unknown; - constructor(value: unknown); - } - - class LanguageModelToolResultPart { - callId: string; - content: Array; - constructor(callId: string, content: Array); - } - - class LanguageModelChatMessage { - static User(content: string | Array, name?: string): LanguageModelChatMessage; - static Assistant(content: string | Array, name?: string): LanguageModelChatMessage; - - role: LanguageModelChatMessageRole; - content: Array; - name: string | undefined; - - constructor(role: LanguageModelChatMessageRole, content: string | Array, name?: string); - } - - namespace lm { - function selectChatModels(selector?: LanguageModelChatSelector): Thenable; - } -} diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index c382f39..1322526 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -34,6 +34,7 @@ import { import { ExtensionMessage } from "../../../../src/shared/ExtensionMessage" import { useExtensionState } from "../../context/ExtensionStateContext" import { vscode } from "../../utils/vscode" +import * as vscodemodels from "vscode" import VSCodeButtonLink from "../common/VSCodeButtonLink" import OpenRouterModelPicker, { ModelDescriptionMarkdown, @@ -52,7 +53,7 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage }: const { apiConfiguration, setApiConfiguration, uriScheme } = useExtensionState() const [ollamaModels, setOllamaModels] = useState([]) const [lmStudioModels, setLmStudioModels] = useState([]) - const [vsCodeLmModels, setVsCodeLmModels] = useState([]) + const [vsCodeLmModels, setVsCodeLmModels] = useState([]) const [anthropicBaseUrlSelected, setAnthropicBaseUrlSelected] = useState(!!apiConfiguration?.anthropicBaseUrl) const [azureApiVersionSelected, setAzureApiVersionSelected] = useState(!!apiConfiguration?.azureApiVersion) const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false) diff --git a/webview-ui/src/types/vscode.d.ts b/webview-ui/src/types/vscode.d.ts deleted file mode 100644 index 9424145..0000000 --- a/webview-ui/src/types/vscode.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace vscode { - interface LanguageModelChatSelector { - vendor?: string; - family?: string; - version?: string; - id?: string; - } -}