|
|
@ -36,6 +36,7 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
isInferencing: boolean = false |
|
|
|
isInferencing: boolean = false |
|
|
|
chatRequestBuffer: chatRequestBufferT<any> = null |
|
|
|
chatRequestBuffer: chatRequestBufferT<any> = null |
|
|
|
agent: CodeExplainAgent |
|
|
|
agent: CodeExplainAgent |
|
|
|
|
|
|
|
useRemoteInferencer:boolean = false |
|
|
|
|
|
|
|
|
|
|
|
constructor(inDesktop:boolean) { |
|
|
|
constructor(inDesktop:boolean) { |
|
|
|
super(profile) |
|
|
|
super(profile) |
|
|
@ -47,11 +48,13 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
onActivation(): void { |
|
|
|
onActivation(): void { |
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop) { |
|
|
|
console.log('Activating RemixAIPlugin on desktop') |
|
|
|
console.log('Activating RemixAIPlugin on desktop') |
|
|
|
this.on(this.remixDesktopPluginName, 'activated', () => { |
|
|
|
// this.on(this.remixDesktopPluginName, 'activated', () => {
|
|
|
|
this.call("remixAI", 'initialize', null, null, null, false); |
|
|
|
this.useRemoteInferencer = true |
|
|
|
}) |
|
|
|
this.initialize(null, null, null, this.useRemoteInferencer); |
|
|
|
|
|
|
|
// })
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
console.log('Activating RemixAIPlugin on browser') |
|
|
|
console.log('Activating RemixAIPlugin on browser') |
|
|
|
|
|
|
|
this.useRemoteInferencer = true |
|
|
|
this.initialize() |
|
|
|
this.initialize() |
|
|
|
} |
|
|
|
} |
|
|
|
// this.setRemixAIOnSidePannel(false)
|
|
|
|
// this.setRemixAIOnSidePannel(false)
|
|
|
@ -67,9 +70,8 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean){ |
|
|
|
async initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean){ |
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop && !this.useRemoteInferencer) { |
|
|
|
// on desktop use remote inferencer -> false
|
|
|
|
// on desktop use remote inferencer -> false
|
|
|
|
console.log('initialize on desktop') |
|
|
|
|
|
|
|
const res = await this.call(this.remixDesktopPluginName, 'initializeModelBackend', useRemote, model1, model2) |
|
|
|
const res = await this.call(this.remixDesktopPluginName, 'initializeModelBackend', useRemote, model1, model2) |
|
|
|
if (res) { |
|
|
|
if (res) { |
|
|
|
this.on(this.remixDesktopPluginName, 'onStreamResult', (value) => { |
|
|
|
this.on(this.remixDesktopPluginName, 'onStreamResult', (value) => { |
|
|
@ -105,7 +107,7 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop && !this.useRemoteInferencer) { |
|
|
|
return await this.call(this.remixDesktopPluginName, 'code_generation', prompt) |
|
|
|
return await this.call(this.remixDesktopPluginName, 'code_generation', prompt) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return await this.remoteInferencer.code_generation(prompt) |
|
|
|
return await this.remoteInferencer.code_generation(prompt) |
|
|
@ -113,7 +115,7 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async code_completion(prompt: string, promptAfter: string): Promise<any> { |
|
|
|
async code_completion(prompt: string, promptAfter: string): Promise<any> { |
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop && !this.useRemoteInferencer) { |
|
|
|
return await this.call(this.remixDesktopPluginName, 'code_completion', prompt, promptAfter) |
|
|
|
return await this.call(this.remixDesktopPluginName, 'code_completion', prompt, promptAfter) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return await this.remoteInferencer.code_completion(prompt, promptAfter) |
|
|
|
return await this.remoteInferencer.code_completion(prompt, promptAfter) |
|
|
@ -128,7 +130,7 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
|
|
|
|
|
|
|
|
const newPrompt = await this.agent.chatCommand(prompt) |
|
|
|
const newPrompt = await this.agent.chatCommand(prompt) |
|
|
|
let result |
|
|
|
let result |
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop && !this.useRemoteInferencer) { |
|
|
|
result = await this.call(this.remixDesktopPluginName, 'solidity_answer', newPrompt) |
|
|
|
result = await this.call(this.remixDesktopPluginName, 'solidity_answer', newPrompt) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
result = await this.remoteInferencer.solidity_answer(newPrompt) |
|
|
|
result = await this.remoteInferencer.solidity_answer(newPrompt) |
|
|
@ -144,7 +146,7 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let result |
|
|
|
let result |
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop && !this.useRemoteInferencer) { |
|
|
|
result = await this.call(this.remixDesktopPluginName, 'code_explaining', prompt, context, params) |
|
|
|
result = await this.call(this.remixDesktopPluginName, 'code_explaining', prompt, context, params) |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -161,7 +163,7 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let result |
|
|
|
let result |
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop && !this.useRemoteInferencer) { |
|
|
|
result = await this.call(this.remixDesktopPluginName, 'error_explaining', prompt) |
|
|
|
result = await this.call(this.remixDesktopPluginName, 'error_explaining', prompt) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
result = await this.remoteInferencer.error_explaining(prompt, params) |
|
|
|
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<any> { |
|
|
|
async code_insertion(msg_pfx: string, msg_sfx: string): Promise<any> { |
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop && !this.useRemoteInferencer) { |
|
|
|
return await this.call(this.remixDesktopPluginName, 'code_insertion', msg_pfx, msg_sfx) |
|
|
|
return await this.call(this.remixDesktopPluginName, 'code_insertion', msg_pfx, msg_sfx) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return await this.remoteInferencer.code_insertion(msg_pfx, msg_sfx) |
|
|
|
return await this.remoteInferencer.code_insertion(msg_pfx, msg_sfx) |
|
|
|