Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed user information popup through vscode showInformationMessage #121

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/configureAssistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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.", ""
);
}
}
Expand All @@ -177,7 +196,9 @@ function isContinueInstalled(): boolean {
return continueExt !== undefined;
}

async function readConfig(configFile: string): Promise<any> {
export const configFilePath = path.join(os.homedir(), ".continue/config.json");

export async function readConfig(configFile: string): Promise<any> {
try {
await fs.access(configFile, fs.constants.R_OK);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion webviews/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function App() {
<p className="m-0 mb-1">
Run <a href="https://github.com/ibm-granite/granite-code-models" target="_blank" rel="noopener noreferrer">IBM Granite Code</a> models effortlessly with
<a href="https://github.com/ollama/ollama" target="_blank" rel="noopener noreferrer"> Ollama</a> and
<a href="https://github.com/continuedev/continue" target="_blank" rel="noopener noreferrer">Continue.dev</a>.
<a href="https://github.com/continuedev/continue" target="_blank" rel="noopener noreferrer">Continue</a>.
Granite will help you write, generate, explain or document code, while your data stays secure and private on your own machine.
</p>
</div>
Expand Down