From 8968ce6b78efa055a70fce33ce6de458c07d537a Mon Sep 17 00:00:00 2001 From: STetsing <41009393+STetsing@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:56:23 +0200 Subject: [PATCH] remixai remote inference working on desktop --- apps/remix-ide/src/app.js | 2 +- .../src/app/plugins/remixAIPlugin.tsx | 24 ++++++++++--------- libs/remix-ai-core/src/types/types.ts | 1 - 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 91b2a42f33..796d354c5c 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -557,7 +557,7 @@ class AppComponent { await this.appManager.activatePlugin(['solidity-script', 'remix-templates']) if (isElectron()) { - await this.appManager.activatePlugin(['isogit', 'electronconfig', 'electronTemplates', 'xterm', 'ripgrep', 'appUpdater', 'slither', 'foundry', 'hardhat', 'remixAID']) + await this.appManager.activatePlugin(['isogit', 'electronconfig', 'electronTemplates', 'xterm', 'ripgrep', 'appUpdater', 'slither', 'foundry', 'hardhat']) // 'remixAID' } this.appManager.on( diff --git a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx index 493f053b56..f6005ee3b3 100644 --- a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx +++ b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx @@ -36,6 +36,7 @@ export class RemixAIPlugin extends ViewPlugin { isInferencing: boolean = false chatRequestBuffer: chatRequestBufferT = null agent: CodeExplainAgent + useRemoteInferencer:boolean = false constructor(inDesktop:boolean) { super(profile) @@ -47,11 +48,13 @@ export class RemixAIPlugin extends ViewPlugin { onActivation(): void { if (this.isOnDesktop) { console.log('Activating RemixAIPlugin on desktop') - this.on(this.remixDesktopPluginName, 'activated', () => { - this.call("remixAI", 'initialize', null, null, null, false); - }) + // this.on(this.remixDesktopPluginName, 'activated', () => { + this.useRemoteInferencer = true + this.initialize(null, null, null, this.useRemoteInferencer); + // }) } else { console.log('Activating RemixAIPlugin on browser') + this.useRemoteInferencer = true this.initialize() } // this.setRemixAIOnSidePannel(false) @@ -67,9 +70,8 @@ export class RemixAIPlugin extends ViewPlugin { } async initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean){ - if (this.isOnDesktop) { + if (this.isOnDesktop && !this.useRemoteInferencer) { // on desktop use remote inferencer -> false - console.log('initialize on desktop') const res = await this.call(this.remixDesktopPluginName, 'initializeModelBackend', useRemote, model1, model2) if (res) { this.on(this.remixDesktopPluginName, 'onStreamResult', (value) => { @@ -105,7 +107,7 @@ export class RemixAIPlugin extends ViewPlugin { return } - if (this.isOnDesktop) { + if (this.isOnDesktop && !this.useRemoteInferencer) { return await this.call(this.remixDesktopPluginName, 'code_generation', prompt) } else { return await this.remoteInferencer.code_generation(prompt) @@ -113,7 +115,7 @@ export class RemixAIPlugin extends ViewPlugin { } async code_completion(prompt: string, promptAfter: string): Promise { - if (this.isOnDesktop) { + if (this.isOnDesktop && !this.useRemoteInferencer) { return await this.call(this.remixDesktopPluginName, 'code_completion', prompt, promptAfter) } else { return await this.remoteInferencer.code_completion(prompt, promptAfter) @@ -128,7 +130,7 @@ export class RemixAIPlugin extends ViewPlugin { const newPrompt = await this.agent.chatCommand(prompt) let result - if (this.isOnDesktop) { + if (this.isOnDesktop && !this.useRemoteInferencer) { result = await this.call(this.remixDesktopPluginName, 'solidity_answer', newPrompt) } else { result = await this.remoteInferencer.solidity_answer(newPrompt) @@ -144,7 +146,7 @@ export class RemixAIPlugin extends ViewPlugin { } let result - if (this.isOnDesktop) { + if (this.isOnDesktop && !this.useRemoteInferencer) { result = await this.call(this.remixDesktopPluginName, 'code_explaining', prompt, context, params) } else { @@ -161,7 +163,7 @@ export class RemixAIPlugin extends ViewPlugin { } let result - if (this.isOnDesktop) { + if (this.isOnDesktop && !this.useRemoteInferencer) { result = await this.call(this.remixDesktopPluginName, 'error_explaining', prompt) } else { result = await this.remoteInferencer.error_explaining(prompt, params) @@ -171,7 +173,7 @@ export class RemixAIPlugin extends ViewPlugin { } async code_insertion(msg_pfx: string, msg_sfx: string): Promise { - if (this.isOnDesktop) { + if (this.isOnDesktop && !this.useRemoteInferencer) { return await this.call(this.remixDesktopPluginName, 'code_insertion', msg_pfx, msg_sfx) } else { return await this.remoteInferencer.code_insertion(msg_pfx, msg_sfx) diff --git a/libs/remix-ai-core/src/types/types.ts b/libs/remix-ai-core/src/types/types.ts index b170fc6259..a6d2c9eb88 100644 --- a/libs/remix-ai-core/src/types/types.ts +++ b/libs/remix-ai-core/src/types/types.ts @@ -118,7 +118,6 @@ export class JsonStreamParser { const jsonStr = this.buffer.slice(startIndex, endIndex + 1); try { const obj: GeneratedTextObject = JSON.parse(jsonStr); - console.log('parsed:', obj); results.push(obj); } catch (error) { console.error('Error parsing JSON:', error);