switched open gpt to solcoder for error explaining

remixai-plugin
Stéphane Tetsing 6 months ago
parent 9a971b0c22
commit a1f44f6123
  1. 2
      apps/circuit-compiler/src/app/components/feedbackAlert.tsx
  2. 31
      apps/remix-ide/src/app/plugins/solcoderAI.tsx
  3. 5
      apps/vyper/src/app/utils/remix-client.tsx
  4. 6
      libs/remix-ui/renderer/src/lib/renderer.tsx
  5. 5
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx
  6. 3
      libs/remix-ui/terminal/src/lib/terminalWelcome.tsx

@ -24,7 +24,7 @@ export function FeedbackAlert ({ message, askGPT }: FeedbackAlertProps) {
<span className="border border-success text-success btn-sm" onClick={(e) => { <span className="border border-success text-success btn-sm" onClick={(e) => {
e.stopPropagation() e.stopPropagation()
askGPT() askGPT()
}}>ASK GPT</span> }}>ASK SOL-GPT</span>
</div> </div>
</> </>
</RenderIf> </RenderIf>

@ -15,7 +15,7 @@ const profile = {
name: 'solcoder', name: 'solcoder',
displayName: 'solcoder', displayName: 'solcoder',
description: 'solcoder', description: 'solcoder',
methods: ['code_generation', 'code_completion', "solidity_answer", "code_explaining", "code_insertion"], methods: ['code_generation', 'code_completion', "solidity_answer", "code_explaining", "code_insertion", "error_explaining"],
events: [], events: [],
maintainedBy: 'Remix', maintainedBy: 'Remix',
} }
@ -218,6 +218,35 @@ export class SolCoder extends Plugin {
} }
} }
async error_explaining(prompt): Promise<any> {
this.emit("aiInfering")
this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for SOL-GPT answer...` })
let result
try {
result = await(
await fetch(this.api_url, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({ "data":[prompt, "error_explaining", false,2000,0.9,0.8,50]}),
})
).json()
if (result) {
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] })
}
return result.data[0]
} catch (e) {
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` })
return
} finally {
this.emit("aiInferingDone")
}
}
_build_solgpt_promt(user_promt:string){ _build_solgpt_promt(user_promt:string){
if (this.solgpt_chat_history.length === 0){ if (this.solgpt_chat_history.length === 0){
return user_promt return user_promt

@ -5,6 +5,7 @@ import {PluginClient} from '@remixproject/plugin'
import {Contract, compileContract} from './compiler' import {Contract, compileContract} from './compiler'
import {ExampleContract} from '../components/VyperResult' import {ExampleContract} from '../components/VyperResult'
import EventEmitter from 'events' import EventEmitter from 'events'
const _paq = (window._paq = window._paq || [])
export type VyperComplierAddress = 'https://vyper2.remixproject.org/' | 'http://localhost:8000/' export type VyperComplierAddress = 'https://vyper2.remixproject.org/' | 'http://localhost:8000/'
@ -66,11 +67,13 @@ export class RemixClient extends PluginClient {
return return
} }
try { try {
// TODO: remove! no formatting required since already handled on server
const formattedMessage = ` const formattedMessage = `
${message} ${message}
can you explain why this error occurred and how to fix it? can you explain why this error occurred and how to fix it?
` `
await this.client.call('openaigpt' as any, 'message', formattedMessage) await this.client.call('solcoder' as any, 'error_explaining', message)
_paq.push(['trackEvent', 'ai', 'solcoder', 'error_explaining'])
} catch (err) { } catch (err) {
console.error('unable to askGpt') console.error('unable to askGpt')
console.error(err) console.error(err)

@ -75,8 +75,8 @@ export const Renderer = ({ message, opt = {}, plugin }: 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: 'solidity.openaigptMessage' }, { content, messageText }) const message = intl.formatMessage({ id: 'solidity.openaigptMessage' }, { content, messageText })
await plugin.call('openaigpt', 'message', message) await plugin.call('solcoder', 'error_explaining', message)
_paq.push(['trackEvent', 'ai', 'openai', 'explainSolidityError']) _paq.push(['trackEvent', 'ai', 'solcoder', 'error_explaining_SolidityError'])
} catch (err) { } catch (err) {
console.error('unable to askGtp') console.error('unable to askGtp')
console.error(err) console.error(err)
@ -111,7 +111,7 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => {
onClick={() => { askGtp() }} onClick={() => { askGtp() }}
style={{ borderColor: "var(--ai)" }} style={{ borderColor: "var(--ai)" }}
> >
ASK GPT ASK SOL-GPT
</span> </span>
</div> </div>

@ -235,10 +235,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
try { try {
if (script.trim().startsWith('git')) { if (script.trim().startsWith('git')) {
// await this.call('git', 'execute', script) code might be used in the future // await this.call('git', 'execute', script) code might be used in the future
// TODO: rm gpt or redirect gpt to sol-pgt
} else if (script.trim().startsWith('gpt')) { } else if (script.trim().startsWith('gpt')) {
call('terminal', 'log',{ type: 'warn', value: `> ${script}` }) call('terminal', 'log',{ type: 'warn', value: `> ${script}` })
await call('openaigpt', 'message', script) await call('solcoder', 'solidity_answer', script)
_paq.push(['trackEvent', 'ai', 'openai', 'askFromTerminal']) _paq.push(['trackEvent', 'ai', 'solcoder', 'askFromTerminal'])
} else if (script.trim().startsWith('sol-gpt')) { } else if (script.trim().startsWith('sol-gpt')) {
call('terminal', 'log',{ type: 'warn', value: `> ${script}` }) call('terminal', 'log',{ type: 'warn', value: `> ${script}` })
await call('solcoder', 'solidity_answer', script) await call('solcoder', 'solidity_answer', script)

@ -54,9 +54,6 @@ const TerminalWelcomeMessage = ({ packageJson, storage }) => {
ethers.js ethers.js
</a>{' '} </a>{' '}
</li> </li>
<li key="gpt">
gpt <i>&lt;your question here&gt;</i> {' '}
</li>
<li key="sol-gpt"> <li key="sol-gpt">
sol-gpt <i>&lt;your Solidity question here&gt;</i> {' '} sol-gpt <i>&lt;your Solidity question here&gt;</i> {' '}
</li> </li>

Loading…
Cancel
Save