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