calling popuppannel and fixed sol/gpt command in terminal

pull/5383/head
STetsing 2 weeks ago committed by Aniket
parent 6be65c8824
commit 9ac8dfb226
  1. 15
      apps/circuit-compiler/src/app/components/container.tsx
  2. 5
      apps/remix-ide/src/app/plugins/remixAIPlugin.tsx
  3. 6
      apps/vyper/src/app/utils/remix-client.tsx
  4. 1
      libs/remix-ai-core/src/helpers/streamHandler.ts
  5. 18
      libs/remix-ai-core/src/inferencers/remote/remoteInference.ts
  6. 6
      libs/remix-ui/renderer/src/lib/renderer.tsx
  7. 27
      libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx

@ -73,14 +73,20 @@ export function Container () {
full circom error: ${JSON.stringify(report, null, 2)} full circom error: ${JSON.stringify(report, null, 2)}
explain why the error occurred and how to fix it. explain why the error occurred and how to fix it.
` `
await circuitApp.plugin.call('remixAI' as any, 'chatPipe', 'error_explaining', message) await circuitApp.plugin.call('popupPanel' as any, 'showPopupPanel', true)
setTimeout(async () => {
await circuitApp.plugin.call('remixAI' as any, 'chatPipe', 'error_explaining', message)
}, 500)
} else { } else {
const message = ` const message = `
error message: ${error} error message: ${error}
full circom error: ${JSON.stringify(report, null, 2)} full circom error: ${JSON.stringify(report, null, 2)}
explain why the error occurred and how to fix it. explain why the error occurred and how to fix it.
` `
await circuitApp.plugin.call('remixAI' as any, 'chatPipe', 'error_explaining', message) await circuitApp.plugin.call('popupPanel' as any, 'showPopupPanel', true)
setTimeout(async () => {
await circuitApp.plugin.call('remixAI' as any, 'chatPipe', 'error_explaining', message)
}, 500)
} }
} else { } else {
const error = report.message const error = report.message
@ -89,7 +95,10 @@ export function Container () {
full circom error: ${JSON.stringify(report, null, 2)} full circom error: ${JSON.stringify(report, null, 2)}
explain why the error occurred and how to fix it. explain why the error occurred and how to fix it.
` `
await circuitApp.plugin.call('remixAI' as any, 'chatPipe', 'error_explaining', message) await circuitApp.plugin.call('popupPanel' as any, 'showPopupPanel', true)
setTimeout(async () => {
await circuitApp.plugin.call('remixAI' as any, 'chatPipe', 'error_explaining', message)
}, 500)
} }
} }

@ -121,6 +121,11 @@ 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
} }
if (prompt.trimStart().startsWith('gpt') || prompt.trimStart().startsWith('sol-gpt')) {
params.terminal_output = true
params.stream_result = false
params.return_stream_response = false
}
const newPrompt = await this.agent.chatCommand(prompt) const newPrompt = await this.agent.chatCommand(prompt)
let result let result

@ -71,7 +71,11 @@ export class RemixClient extends PluginClient<any, CustomRemixApi> {
const file = await this.client.call('fileManager', 'getCurrentFile') const file = await this.client.call('fileManager', 'getCurrentFile')
const content = await this.client.call('fileManager', 'readFile', file) const content = await this.client.call('fileManager', 'readFile', file)
const messageAI = `Vyper code: ${content}\n error message: ${message}\n explain why the error occurred and how to fix it.` const messageAI = `Vyper code: ${content}\n error message: ${message}\n explain why the error occurred and how to fix it.`
await this.client.call('remixAI' as any, 'chatPipe', 'error_explaining', messageAI)
await this.client.plugin.call('popupPanel', 'showPopupPanel', true)
setTimeout(async () => {
await this.client.plugin.call('remixAI' as any, 'chatPipe', 'error_explaining', messageAI)
}, 500)
} catch (err) { } catch (err) {
console.error('unable to askGpt') console.error('unable to askGpt')
console.error(err) console.error(err)

@ -54,6 +54,7 @@ export const HandleStreamResponse = async (streamResponse,
} }
catch (error) { catch (error) {
console.error('Error parsing JSON:', error); console.error('Error parsing JSON:', error);
return { 'generateText': '', 'isGenerating': false }
} }
} }

@ -27,7 +27,7 @@ export class RemoteInferencer implements ICompletions {
try { try {
const options = { headers: { 'Content-Type': 'application/json', } } const options = { headers: { 'Content-Type': 'application/json', } }
const result = await axios.post(`${requestURL}`, payload, options) const result = await axios.post(requestURL, payload, options)
switch (rType) { switch (rType) {
case AIRequestType.COMPLETION: case AIRequestType.COMPLETION:
@ -56,7 +56,7 @@ export class RemoteInferencer implements ICompletions {
} }
} }
private async _streamInferenceRequest(endpoint, payload, rType:AIRequestType){ private async _streamInferenceRequest(payload, rType:AIRequestType){
let resultText = "" let resultText = ""
try { try {
this.event.emit('onInference') this.event.emit('onInference')
@ -122,26 +122,32 @@ export class RemoteInferencer implements ICompletions {
async code_generation(prompt, options:IParams=GenerationParams): Promise<any> { async code_generation(prompt, options:IParams=GenerationParams): Promise<any> {
const payload = { prompt, "endpoint":"code_completion", ...options } const payload = { prompt, "endpoint":"code_completion", ...options }
if (options.stream_result) return this._streamInferenceRequest(payload.endpoint, payload, AIRequestType.COMPLETION) if (options.stream_result) return this._streamInferenceRequest(payload, AIRequestType.COMPLETION)
else return this._makeRequest(payload, AIRequestType.COMPLETION) else return this._makeRequest(payload, AIRequestType.COMPLETION)
} }
async solidity_answer(prompt, options:IParams=GenerationParams): Promise<any> { async solidity_answer(prompt, options:IParams=GenerationParams): Promise<any> {
const main_prompt = buildSolgptPromt(prompt, this.model_op) const main_prompt = buildSolgptPromt(prompt, this.model_op)
const payload = { 'prompt': main_prompt, "endpoint":"solidity_answer", ...options } const payload = { 'prompt': main_prompt, "endpoint":"solidity_answer", ...options }
if (options.stream_result) return this._streamInferenceRequest(payload.endpoint, payload, AIRequestType.GENERAL) if (options.stream_result) return this._streamInferenceRequest(payload, AIRequestType.GENERAL)
else return this._makeRequest(payload, AIRequestType.GENERAL) else return this._makeRequest(payload, AIRequestType.GENERAL)
} }
async code_explaining(prompt, context:string="", options:IParams=GenerationParams): Promise<any> { async code_explaining(prompt, context:string="", options:IParams=GenerationParams): Promise<any> {
const payload = { prompt, "endpoint":"code_explaining", context, ...options } const payload = { prompt, "endpoint":"code_explaining", context, ...options }
if (options.stream_result) return this._streamInferenceRequest(payload.endpoint, payload, AIRequestType.GENERAL) if (options.stream_result) return this._streamInferenceRequest(payload, AIRequestType.GENERAL)
else return this._makeRequest(payload, AIRequestType.GENERAL) else return this._makeRequest(payload, AIRequestType.GENERAL)
} }
async error_explaining(prompt, options:IParams=GenerationParams): Promise<any> { async error_explaining(prompt, options:IParams=GenerationParams): Promise<any> {
const payload = { prompt, "endpoint":"error_explaining", ...options } const payload = { prompt, "endpoint":"error_explaining", ...options }
if (options.stream_result) return this._streamInferenceRequest(payload.endpoint, payload, AIRequestType.GENERAL) if (options.stream_result) return this._streamInferenceRequest(payload, AIRequestType.GENERAL)
else return this._makeRequest(payload, AIRequestType.GENERAL)
}
async vulnerability_check(prompt, options:IParams=GenerationParams): Promise<any> {
const payload = { prompt, "endpoint":"vulnerability_check", ...options }
if (options.stream_result) return this._streamInferenceRequest(payload, AIRequestType.GENERAL)
else return this._makeRequest(payload, AIRequestType.GENERAL) else return this._makeRequest(payload, AIRequestType.GENERAL)
} }
} }

@ -90,7 +90,11 @@ export const Renderer = ({ message, opt, plugin, context }: RendererProps) => {
try { try {
const content = await plugin.call('fileManager', 'readFile', editorOptions.errFile) const content = await plugin.call('fileManager', 'readFile', editorOptions.errFile)
const message = intl.formatMessage({ id: `${context || 'solidity' }.openaigptMessage` }, { content, messageText }) const message = intl.formatMessage({ id: `${context || 'solidity' }.openaigptMessage` }, { content, messageText })
await plugin.call('remixAI' as any, 'chatPipe', 'error_explaining', message)
await plugin.call('popupPanel', 'showPopupPanel', true)
setTimeout(async () => {
await plugin.call('remixAI' as any, 'chatPipe', 'error_explaining', message)
}, 500)
_paq.push(['trackEvent', 'ai', 'remixAI', 'error_explaining_SolidityError']) _paq.push(['trackEvent', 'ai', 'remixAI', 'error_explaining_SolidityError'])
} catch (err) { } catch (err) {
console.error('unable to askGtp') console.error('unable to askGtp')

@ -269,31 +269,10 @@ export const TabsUI = (props: TabsUIProps) => {
if (tabsState.currentExt === 'sol') { if (tabsState.currentExt === 'sol') {
setExplaining(true) setExplaining(true)
// if plugin is pinned, // if plugin is pinned,
if (await props.plugin.call('pinnedPanel', 'currentFocus') === 'remixAI'){ await props.plugin.call('popupPanel', 'showPopupPanel', true)
setTimeout(async () => {
await props.plugin.call('remixAI', 'chatPipe', 'code_explaining', content) await props.plugin.call('remixAI', 'chatPipe', 'code_explaining', content)
} }, 500)
else {
const profile = {
name: 'remixAI',
displayName: 'Remix AI',
methods: ['code_generation', 'code_completion',
"solidity_answer", "code_explaining",
"code_insertion", "error_explaining",
"initialize", 'chatPipe', 'ProcessChatRequestBuffer', 'isChatRequestPending'],
events: [],
icon: 'assets/img/remix-logo-blue.png',
description: 'RemixAI provides AI services to Remix IDE.',
kind: '',
location: 'sidePanel',
documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html',
maintainedBy: 'Remix'
}
// await props.plugin.call('sidePanel', 'focus', 'remixAI')
await props.plugin.call('sidePanel', 'pinView', profile)
setTimeout(async () => {
await props.plugin.call('remixAI', 'chatPipe', 'code_explaining', content)
}, 500)
}
setExplaining(false) setExplaining(false)
_paq.push(['trackEvent', 'ai', 'remixAI', 'explain_file']) _paq.push(['trackEvent', 'ai', 'remixAI', 'explain_file'])
} }

Loading…
Cancel
Save