فهرست منبع

Add 'supports computer use' prop; sync latest openrouter info on launch

Saoud Rizwan 1 سال پیش
والد
کامیت
17f34e6225
3فایلهای تغییر یافته به همراه36 افزوده شده و 4 حذف شده
  1. 24 3
      src/core/webview/ClineProvider.ts
  2. 6 1
      src/shared/api.ts
  3. 6 0
      webview-ui/src/components/settings/ApiOptions.tsx

+ 24 - 3
src/core/webview/ClineProvider.ts

@@ -305,12 +305,26 @@ export class ClineProvider implements vscode.WebviewViewProvider {
 						getTheme().then((theme) =>
 							this.postMessageToWebview({ type: "theme", text: JSON.stringify(theme) })
 						)
+						// post last cached models in case the call to endpoint fails
 						this.readOpenRouterModels().then((openRouterModels) => {
 							if (openRouterModels) {
 								this.postMessageToWebview({ type: "openRouterModels", openRouterModels })
-							} else {
-								// nothing cached, fetch first time
-								this.refreshOpenRouterModels()
+							}
+						})
+						// gui relies on model info to be up-to-date to provide the most accurate pricing, so we need to fetch the latest details on launch.
+						// we do this for all users since many users switch between api providers and if they were to switch back to openrouter it would be showing outdated model info if we hadn't retrieved the latest at this point
+						// (see normalizeApiConfiguration > openrouter)
+						this.refreshOpenRouterModels().then(async (openRouterModels) => {
+							if (openRouterModels) {
+								// update model info in state (this needs to be done here since we don't want to update state while settings is open, and we may refresh models there)
+								const { apiConfiguration } = await this.getState()
+								if (apiConfiguration.openRouterModelId) {
+									await this.updateGlobalState(
+										"openRouterModelInfo",
+										openRouterModels[apiConfiguration.openRouterModelId]
+									)
+									await this.postStateToWebview()
+								}
 							}
 						})
 						break
@@ -594,6 +608,12 @@ export class ClineProvider implements vscode.WebviewViewProvider {
 					switch (rawModel.id) {
 						case "anthropic/claude-3.5-sonnet":
 						case "anthropic/claude-3.5-sonnet:beta":
+							// NOTE: this needs to be synced with api.ts/openrouter default model info
+							modelInfo.supportsComputerUse = true
+							modelInfo.supportsPromptCache = true
+							modelInfo.cacheWritesPrice = 3.75
+							modelInfo.cacheReadsPrice = 0.3
+							break
 						case "anthropic/claude-3.5-sonnet-20240620":
 						case "anthropic/claude-3.5-sonnet-20240620:beta":
 							modelInfo.supportsPromptCache = true
@@ -626,6 +646,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
 		}
 
 		await this.postMessageToWebview({ type: "openRouterModels", openRouterModels: models })
+		return models
 	}
 
 	// Task history

+ 6 - 1
src/shared/api.ts

@@ -41,6 +41,7 @@ export interface ModelInfo {
 	maxTokens?: number
 	contextWindow?: number
 	supportsImages?: boolean
+	supportsComputerUse?: boolean
 	supportsPromptCache: boolean // this value is hardcoded for now
 	inputPrice?: number
 	outputPrice?: number
@@ -58,6 +59,7 @@ export const anthropicModels = {
 		maxTokens: 8192,
 		contextWindow: 200_000,
 		supportsImages: true,
+		supportsComputerUse: true,
 		supportsPromptCache: true,
 		inputPrice: 3.0, // $3 per million input tokens
 		outputPrice: 15.0, // $15 per million output tokens
@@ -95,6 +97,7 @@ export const bedrockModels = {
 		maxTokens: 8192,
 		contextWindow: 200_000,
 		supportsImages: true,
+		supportsComputerUse: true,
 		supportsPromptCache: false,
 		inputPrice: 3.0,
 		outputPrice: 15.0,
@@ -132,13 +135,14 @@ export const openRouterDefaultModelInfo: ModelInfo = {
 	maxTokens: 8192,
 	contextWindow: 200_000,
 	supportsImages: true,
+	supportsComputerUse: true,
 	supportsPromptCache: true,
 	inputPrice: 3.0,
 	outputPrice: 15.0,
 	cacheWritesPrice: 3.75,
 	cacheReadsPrice: 0.3,
 	description:
-		"Claude 3.5 Sonnet delivers better-than-Opus capabilities, faster-than-Sonnet speeds, at the same Sonnet prices. Sonnet is particularly good at:\n\n- Coding: Autonomously writes, edits, and runs code with reasoning and troubleshooting\n- Data science: Augments human data science expertise; navigates unstructured data while using multiple tools for insights\n- Visual processing: excelling at interpreting charts, graphs, and images, accurately transcribing text to derive insights beyond just the text alone\n- Agentic tasks: exceptional tool use, making it great at agentic tasks (i.e. complex, multi-step problem solving tasks that require engaging with other systems)\n\n#multimodal\n\n_This is a faster endpoint, made available in collaboration with Anthropic, that is self-moderated: response moderation happens on the provider's side instead of OpenRouter's. For requests that pass moderation, it's identical to the [Standard](/models/anthropic/claude-3.5-sonnet) variant._",
+		"The new Claude 3.5 Sonnet delivers better-than-Opus capabilities, faster-than-Sonnet speeds, at the same Sonnet prices. Sonnet is particularly good at:\n\n- Coding: New Sonnet scores ~49% on SWE-Bench Verified, higher than the last best score, and without any fancy prompt scaffolding\n- Data science: Augments human data science expertise; navigates unstructured data while using multiple tools for insights\n- Visual processing: excelling at interpreting charts, graphs, and images, accurately transcribing text to derive insights beyond just the text alone\n- Agentic tasks: exceptional tool use, making it great at agentic tasks (i.e. complex, multi-step problem solving tasks that require engaging with other systems)\n\n#multimodal\n\n_This is a faster endpoint, made available in collaboration with Anthropic, that is self-moderated: response moderation happens on the provider's side instead of OpenRouter's. For requests that pass moderation, it's identical to the [Standard](/anthropic/claude-3.5-sonnet) variant._",
 }
 
 // Vertex AI
@@ -150,6 +154,7 @@ export const vertexModels = {
 		maxTokens: 8192,
 		contextWindow: 200_000,
 		supportsImages: true,
+		supportsComputerUse: true,
 		supportsPromptCache: false,
 		inputPrice: 3.0,
 		outputPrice: 15.0,

+ 6 - 0
webview-ui/src/components/settings/ApiOptions.tsx

@@ -610,6 +610,12 @@ export const ModelInfoView = ({
 			supportsLabel="Supports images"
 			doesNotSupportLabel="Does not support images"
 		/>,
+		<ModelInfoSupportsItem
+			key="supportsComputerUse"
+			isSupported={modelInfo.supportsComputerUse ?? false}
+			supportsLabel="Supports computer use"
+			doesNotSupportLabel="Does not support computer use"
+		/>,
 		!isGemini && (
 			<ModelInfoSupportsItem
 				key="supportsPromptCache"