Enhance prompt button for openrouter

This commit is contained in:
Matt Rubens
2024-12-23 23:24:49 -08:00
parent 1581ed135b
commit 111abdbb2c
13 changed files with 703 additions and 102 deletions

View File

@@ -23,6 +23,7 @@ import { openMention } from "../mentions"
import { getNonce } from "./getNonce"
import { getUri } from "./getUri"
import { playSound, setSoundEnabled, setSoundVolume } from "../../utils/sound"
import { enhancePrompt } from "../../utils/enhance-prompt"
/*
https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
@@ -637,6 +638,26 @@ export class ClineProvider implements vscode.WebviewViewProvider {
await this.updateGlobalState("writeDelayMs", message.value)
await this.postStateToWebview()
break
case "enhancePrompt":
if (message.text) {
try {
const { apiConfiguration } = await this.getState()
const enhanceConfig = {
...apiConfiguration,
apiProvider: "openrouter" as const,
openRouterModelId: "gpt-4o",
}
const enhancedPrompt = await enhancePrompt(enhanceConfig, message.text)
await this.postMessageToWebview({
type: "enhancedPrompt",
text: enhancedPrompt
})
} catch (error) {
console.error("Error enhancing prompt:", error)
vscode.window.showErrorMessage("Failed to enhance prompt")
}
}
break
}
},
null,