|
|
@ -73,7 +73,6 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// on browser
|
|
|
|
|
|
|
|
this.remoteInferencer = new RemoteInferencer(remoteModel?.apiUrl, remoteModel?.completionUrl) |
|
|
|
this.remoteInferencer = new RemoteInferencer(remoteModel?.apiUrl, remoteModel?.completionUrl) |
|
|
|
this.remoteInferencer.event.on('onInference', () => { |
|
|
|
this.remoteInferencer.event.on('onInference', () => { |
|
|
|
this.isInferencing = true |
|
|
|
this.isInferencing = true |
|
|
@ -114,8 +113,6 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for RemixAI answer...` }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let result |
|
|
|
let result |
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop) { |
|
|
|
result = await this.call(this.remixDesktopPluginName, 'solidity_answer', prompt) |
|
|
|
result = await this.call(this.remixDesktopPluginName, 'solidity_answer', prompt) |
|
|
@ -123,7 +120,6 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
result = await this.remoteInferencer.solidity_answer(prompt) |
|
|
|
result = await this.remoteInferencer.solidity_answer(prompt) |
|
|
|
} |
|
|
|
} |
|
|
|
if (result && params.terminal_output) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result }) |
|
|
|
if (result && params.terminal_output) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result }) |
|
|
|
// this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI Done" })
|
|
|
|
|
|
|
|
return result |
|
|
|
return result |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -132,8 +128,6 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI is already busy!" }) |
|
|
|
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI is already busy!" }) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for RemixAI answer...` }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let result |
|
|
|
let result |
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop) { |
|
|
@ -143,33 +137,22 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
result = await this.remoteInferencer.code_explaining(prompt, context, params) |
|
|
|
result = await this.remoteInferencer.code_explaining(prompt, context, params) |
|
|
|
} |
|
|
|
} |
|
|
|
if (result && params.terminal_output) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result }) |
|
|
|
if (result && params.terminal_output) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result }) |
|
|
|
// this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI Done" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// HandleStreamResponse(result, (text) => {
|
|
|
|
|
|
|
|
// this.call('terminal', 'log', { type: 'aitypewriterwarning', value: text })
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
return result |
|
|
|
return result |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async error_explaining(prompt: string): Promise<any> { |
|
|
|
async error_explaining(prompt: string, context: string="", params: IParams=GenerationParams): Promise<any> { |
|
|
|
if (this.isInferencing) { |
|
|
|
if (this.isInferencing) { |
|
|
|
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI is already busy!" }) |
|
|
|
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI is already busy!" }) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const params:IParams = GenerationParams |
|
|
|
|
|
|
|
params.stream_result = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for RemixAI answer...` }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let result |
|
|
|
let result |
|
|
|
if (this.isOnDesktop) { |
|
|
|
if (this.isOnDesktop) { |
|
|
|
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) |
|
|
|
} |
|
|
|
} |
|
|
|
if (result) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result }) |
|
|
|
if (result && params.terminal_output) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result }) |
|
|
|
// this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "RemixAI Done" })
|
|
|
|
|
|
|
|
return result |
|
|
|
return result |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -181,20 +164,20 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
chatPipe(fn, prompt: string, context?: string, params: IParams=GenerationParams){ |
|
|
|
chatPipe(fn, prompt: string, context?: string, pipeMessage?: string){ |
|
|
|
if (this.chatRequestBuffer == null){ |
|
|
|
if (this.chatRequestBuffer == null){ |
|
|
|
this.chatRequestBuffer = { |
|
|
|
this.chatRequestBuffer = { |
|
|
|
fn_name: fn, |
|
|
|
fn_name: fn, |
|
|
|
prompt: prompt, |
|
|
|
prompt: prompt, |
|
|
|
params: params, |
|
|
|
|
|
|
|
context: context |
|
|
|
context: context |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
console.log('pipe message', pipeMessage) |
|
|
|
if (fn === "code_explaining"){ |
|
|
|
if (pipeMessage) ChatApi.composer.send(pipeMessage) |
|
|
|
ChatApi.composer.send("Explain the current code") |
|
|
|
else { |
|
|
|
} |
|
|
|
if (fn === "code_explaining") ChatApi.composer.send("Explain the current code") |
|
|
|
else if (fn === "solidity_answer"){ |
|
|
|
else if (fn === "error_explaining") ChatApi.composer.send("Explain the error") |
|
|
|
ChatApi.composer.send("Answer the following question") |
|
|
|
else if (fn === "solidity_answer") ChatApi.composer.send("Answer the following question") |
|
|
|
|
|
|
|
else console.log("chatRequestBuffer is not empty. First process the last request.") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
@ -202,7 +185,8 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ProcessChatRequestBuffer(params:IParams=GenerationParams){ |
|
|
|
|
|
|
|
|
|
|
|
async ProcessChatRequestBuffer(params:IParams=GenerationParams){ |
|
|
|
if (this.chatRequestBuffer != null){ |
|
|
|
if (this.chatRequestBuffer != null){ |
|
|
|
const result = this[this.chatRequestBuffer.fn_name](this.chatRequestBuffer.prompt, this.chatRequestBuffer.context, params) |
|
|
|
const result = this[this.chatRequestBuffer.fn_name](this.chatRequestBuffer.prompt, this.chatRequestBuffer.context, params) |
|
|
|
this.chatRequestBuffer = null |
|
|
|
this.chatRequestBuffer = null |
|
|
@ -210,14 +194,13 @@ export class RemixAIPlugin extends ViewPlugin { |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
console.log("chatRequestBuffer is empty.") |
|
|
|
console.log("chatRequestBuffer is empty.") |
|
|
|
|
|
|
|
return "" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
isChatRequestPending(){ |
|
|
|
isChatRequestPending(){ |
|
|
|
return this.chatRequestBuffer != null |
|
|
|
return this.chatRequestBuffer != null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<RemixAITab plugin={this}></RemixAITab> |
|
|
|
<RemixAITab plugin={this}></RemixAITab> |
|
|
|