switched open gpt to solcoder for error explaining

pull/4809/head
Stéphane Tetsing 6 months ago committed by Aniket
parent bc9e9fd266
commit b6dd9261bc
  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) => {
e.stopPropagation()
askGPT()
}}>ASK GPT</span>
}}>ASK SOL-GPT</span>
</div>
</>
</RenderIf>

@ -15,7 +15,7 @@ const profile = {
name: 'solcoder',
displayName: '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: [],
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){
if (this.solgpt_chat_history.length === 0){
return user_promt

@ -5,6 +5,7 @@ import {PluginClient} from '@remixproject/plugin'
import {Contract, compileContract} from './compiler'
import {ExampleContract} from '../components/VyperResult'
import EventEmitter from 'events'
const _paq = (window._paq = window._paq || [])
export type VyperComplierAddress = 'https://vyper2.remixproject.org/' | 'http://localhost:8000/'
@ -66,11 +67,13 @@ export class RemixClient extends PluginClient {
return
}
try {
// TODO: remove! no formatting required since already handled on server
const formattedMessage = `
${message}
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) {
console.error('unable to askGpt')
console.error(err)

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

@ -235,10 +235,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
try {
if (script.trim().startsWith('git')) {
// 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')) {
call('terminal', 'log',{ type: 'warn', value: `> ${script}` })
await call('openaigpt', 'message', script)
_paq.push(['trackEvent', 'ai', 'openai', 'askFromTerminal'])
await call('solcoder', 'solidity_answer', script)
_paq.push(['trackEvent', 'ai', 'solcoder', 'askFromTerminal'])
} else if (script.trim().startsWith('sol-gpt')) {
call('terminal', 'log',{ type: 'warn', value: `> ${script}` })
await call('solcoder', 'solidity_answer', script)

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

Loading…
Cancel
Save