From 9377aa02c661c07f75675d462e2e9af32f301318 Mon Sep 17 00:00:00 2001 From: Sachin Suresh IBM Date: Tue, 5 Nov 2024 19:36:33 +0530 Subject: [PATCH] changed user information popup through vscode showInformationMessage (#121) Signed-off-by: sachinsuresh-s10 --- src/configureAssistant.ts | 25 +++++++++++++++++++++++-- webviews/src/App.tsx | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/configureAssistant.ts b/src/configureAssistant.ts index 1fc272f..3629584 100644 --- a/src/configureAssistant.ts +++ b/src/configureAssistant.ts @@ -103,6 +103,14 @@ export class AiAssistantConfigurator { this.apiBase = DEFAULT_API_BASE; } + private async mightShowContinueOnboarding(configFile: string) { + const config = await readConfig(configFile); + if (!config || !config.models) { + return false; + } + return config.models.length === 1 && config.models[0].provider === "anthropic" && config.models[0].apiKey === ""; + } + public async openWizard() { if (isContinueInstalled()) { await this.configureAssistant(); @@ -117,6 +125,8 @@ export class AiAssistantConfigurator { if (!config) { return vscode.window.showErrorMessage("No ~/.continue/config.json found"); } + // Check if we should show the Continue Onboarding message + const continueOnboardingMightShow = await this.mightShowContinueOnboarding(configFile); // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access const models: ModelConfig[] = config.models === undefined ? [] : config.models; // check if model object is already in the config json @@ -159,8 +169,17 @@ export class AiAssistantConfigurator { if (updateConfig) { await writeConfig(configFile, config); + const currentChatModel = this.request.chatModel ?? null; + let message = "Continue configuration completed."; + if (currentChatModel) { + message += ` Now select '${currentChatModel}' from Continue's chat model dropdown.`; + } + vscode.window.showInformationMessage(message); + } + + if (continueOnboardingMightShow) { vscode.window.showInformationMessage( - `Continue configuration completed.` + "If the Continue view shows onboarding options, they can safely be closed. Otherwise you risk overwriting the Granite configuration.", "" ); } } @@ -177,7 +196,9 @@ function isContinueInstalled(): boolean { return continueExt !== undefined; } -async function readConfig(configFile: string): Promise { +export const configFilePath = path.join(os.homedir(), ".continue/config.json"); + +export async function readConfig(configFile: string): Promise { try { await fs.access(configFile, fs.constants.R_OK); } catch (error) { diff --git a/webviews/src/App.tsx b/webviews/src/App.tsx index b03ff66..fc5b8dc 100644 --- a/webviews/src/App.tsx +++ b/webviews/src/App.tsx @@ -199,7 +199,7 @@ function App() {

Run IBM Granite Code models effortlessly with Ollama and - Continue.dev. + Continue. Granite will help you write, generate, explain or document code, while your data stays secure and private on your own machine.