Skip to content

Commit 2a4235b

Browse files
authored
Merge pull request #4809 from ethereum/ask_sol_gpt
switched open gpt to solcoder for error explaining
2 parents 2e23b58 + 980d738 commit 2a4235b

File tree

14 files changed

+62
-80
lines changed

14 files changed

+62
-80
lines changed

apps/circuit-compiler/src/app/components/container.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function Container () {
5353
const handleCircuitAutoCompile = (value: boolean) => {
5454
circuitApp.dispatch({ type: 'SET_AUTO_COMPILE', payload: value })
5555
}
56-
56+
5757
const handleCircuitHideWarnings = (value: boolean) => {
5858
circuitApp.dispatch({ type: 'SET_HIDE_WARNINGS', payload: value })
5959
}
@@ -73,15 +73,15 @@ export function Container () {
7373
explain why the error occurred and how to fix it.
7474
`
7575
// @ts-ignore
76-
await circuitApp.plugin.call('openaigpt', 'message', message)
76+
await circuitApp.plugin.call('solcoder', 'error_explaining', message)
7777
} else {
7878
const message = `
7979
error message: ${error}
8080
full circom error: ${JSON.stringify(report, null, 2)}
8181
explain why the error occurred and how to fix it.
8282
`
8383
// @ts-ignore
84-
await circuitApp.plugin.call('openaigpt', 'message', message)
84+
await circuitApp.plugin.call('solcoder', 'error_explaining', message)
8585
}
8686
} else {
8787
const error = report.message
@@ -91,7 +91,7 @@ export function Container () {
9191
explain why the error occurred and how to fix it.
9292
`
9393
// @ts-ignore
94-
await circuitApp.plugin.call('openaigpt', 'message', message)
94+
await circuitApp.plugin.call('solcoder', 'error_explaining', message)
9595
}
9696
}
9797

apps/circuit-compiler/src/app/components/feedbackAlert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function FeedbackAlert ({ message, askGPT }: FeedbackAlertProps) {
2424
<span className="border border-success text-success btn-sm" onClick={(e) => {
2525
e.stopPropagation()
2626
askGPT()
27-
}}>ASK GPT</span>
27+
}}>Ask RemixAI</span>
2828
</div>
2929
</>
3030
</RenderIf>

apps/remix-ide/src/app.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ import { electronTemplates } from './app/plugins/electron/templatesPlugin'
5454
import { xtermPlugin } from './app/plugins/electron/xtermPlugin'
5555
import { ripgrepPlugin } from './app/plugins/electron/ripgrepPlugin'
5656
import { compilerLoaderPlugin, compilerLoaderPluginDesktop } from './app/plugins/electron/compilerLoaderPlugin'
57-
58-
import {OpenAIGpt} from './app/plugins/openaigpt'
5957
import {SolCoder} from './app/plugins/solcoderAI'
6058

6159
const isElectron = require('is-electron')
@@ -233,7 +231,6 @@ class AppComponent {
233231
const contractFlattener = new ContractFlattener()
234232

235233
// ----------------- AI --------------------------------------
236-
const openaigpt = new OpenAIGpt()
237234
const solcoder = new SolCoder()
238235

239236
// ----------------- import content service ------------------------
@@ -352,7 +349,6 @@ class AppComponent {
352349
contractFlattener,
353350
solidityScript,
354351
templates,
355-
openaigpt,
356352
solcoder,
357353
pluginStateLogger
358354
])
@@ -512,7 +508,7 @@ class AppComponent {
512508
await this.appManager.registerContextMenuItems()
513509
}
514510
)
515-
await this.appManager.activatePlugin(['solidity-script', 'openaigpt'])
511+
await this.appManager.activatePlugin(['solidity-script'])
516512
await this.appManager.activatePlugin(['solcoder'])
517513

518514

apps/remix-ide/src/app/plugins/openaigpt.tsx

Lines changed: 0 additions & 49 deletions
This file was deleted.

apps/remix-ide/src/app/plugins/solcoderAI.tsx

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const profile = {
1515
name: 'solcoder',
1616
displayName: 'solcoder',
1717
description: 'solcoder',
18-
methods: ['code_generation', 'code_completion', "solidity_answer", "code_explaining", "code_insertion"],
18+
methods: ['code_generation', 'code_completion', "solidity_answer", "code_explaining", "code_insertion", "error_explaining"],
1919
events: [],
2020
maintainedBy: 'Remix',
2121
}
@@ -50,6 +50,8 @@ export class SolCoder extends Plugin {
5050
async code_generation(prompt): Promise<any> {
5151
this.emit("aiInfering")
5252
this.call('layout', 'maximizeTerminal')
53+
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_generation'])
54+
5355
let result
5456
try {
5557
result = await(
@@ -78,6 +80,9 @@ export class SolCoder extends Plugin {
7880
async solidity_answer(prompt): Promise<any> {
7981
this.emit("aiInfering")
8082
this.call('layout', 'maximizeTerminal')
83+
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for RemixAI answer...` })
84+
_paq.push(['trackEvent', 'ai', 'solcoder', 'answering'])
85+
8186
let result
8287
try {
8388
const main_prompt = this._build_solgpt_promt(prompt)
@@ -112,6 +117,9 @@ export class SolCoder extends Plugin {
112117
async code_explaining(prompt, context:string=""): Promise<any> {
113118
this.emit("aiInfering")
114119
this.call('layout', 'maximizeTerminal')
120+
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for RemixAI answer...` })
121+
_paq.push(['trackEvent', 'ai', 'solcoder', 'explaining'])
122+
115123
let result
116124
try {
117125
result = await(
@@ -138,6 +146,8 @@ export class SolCoder extends Plugin {
138146

139147
async code_completion(prompt, options:SuggestOptions=null): Promise<any> {
140148
this.emit("aiInfering")
149+
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_completion'])
150+
141151
let result
142152
try {
143153
result = await(
@@ -184,6 +194,8 @@ export class SolCoder extends Plugin {
184194

185195
async code_insertion(msg_pfx, msg_sfx): Promise<any> {
186196
this.emit("aiInfering")
197+
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_insertion'])
198+
187199
let result
188200
try {
189201
result = await(
@@ -218,6 +230,36 @@ export class SolCoder extends Plugin {
218230
}
219231
}
220232

233+
async error_explaining(prompt): Promise<any> {
234+
this.emit("aiInfering")
235+
this.call('layout', 'maximizeTerminal')
236+
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `\n\nWaiting for RemixAI answer...` })
237+
_paq.push(['trackEvent', 'ai', 'solcoder', 'explaining'])
238+
239+
let result
240+
try {
241+
result = await(
242+
await fetch(this.api_url, {
243+
method: 'POST',
244+
headers: {
245+
Accept: 'application/json',
246+
'Content-Type': 'application/json',
247+
},
248+
body: JSON.stringify({ "data":[prompt, "error_explaining", false,2000,0.9,0.8,50]}),
249+
})
250+
).json()
251+
if (result) {
252+
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] })
253+
}
254+
return result.data[0]
255+
} catch (e) {
256+
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` })
257+
return
258+
} finally {
259+
this.emit("aiInferingDone")
260+
}
261+
}
262+
221263
_build_solgpt_promt(user_promt:string){
222264
if (this.solgpt_chat_history.length === 0){
223265
return user_promt

apps/remix-ide/src/remixAppManager.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ let requiredModules = [ // services + layout views + system views
7171
'vyperCompilationDetails',
7272
'contractflattener',
7373
'solidity-script',
74-
'openaigpt',
7574
'solcoder',
7675
'home',
7776
'doc-viewer',

apps/remix-ide/src/remixEngine.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export class RemixEngine extends Engine {
2626
if (name === 'compilerloader') return { queueTimeout: 60000 * 4 }
2727
if (name === 'filePanel') return { queueTimeout: 60000 * 20 }
2828
if (name === 'fileManager') return { queueTimeout: 60000 * 20 }
29-
if (name === 'openaigpt') return { queueTimeout: 60000 * 2 }
3029
if (name === 'solcoder') return { queueTimeout: 60000 * 2 }
3130
if (name === 'cookbookdev') return { queueTimeout: 60000 * 3 }
3231
return { queueTimeout: 10000 }

apps/vyper/src/app/components/CompileErrorCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function CompileErrorCard(props: { output: any, plugin: RemixClient }) {
2121
<div className="d-flex flex-column pt-3 align-items-end mb-2">
2222
<div>
2323
<span className="border border-ai text-ai btn-sm" onClick={async () => await props.plugin.askGpt(props.output.message)}>
24-
Ask GPT
24+
Ask RemixAI
2525
</span>
2626
<span className="ml-3 pt-1 py-1">
2727
<CopyToClipboard content={props.output.message} className={`p-0 m-0 far fa-copy alert alert-danger`} direction={'top'} />

apps/vyper/src/app/utils/remix-client.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {Contract, compileContract} from './compiler'
66
import {ExampleContract} from '../components/VyperResult'
77
import EventEmitter from 'events'
88

9-
109
export type VyperComplierAddress = 'https://vyper2.remixproject.org/' | 'http://localhost:8000/'
1110
export class RemixClient extends PluginClient {
1211
private client = createClient<Api, Readonly<RemixApi>>(this)
@@ -66,11 +65,12 @@ export class RemixClient extends PluginClient {
6665
return
6766
}
6867
try {
68+
// TODO: remove! no formatting required since already handled on server
6969
const formattedMessage = `
7070
${message}
7171
can you explain why this error occurred and how to fix it?
7272
`
73-
await this.client.call('openaigpt' as any, 'message', formattedMessage)
73+
await this.client.call('solcoder' as any, 'error_explaining', message)
7474
} catch (err) {
7575
console.error('unable to askGpt')
7676
console.error(err)

libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
6666
this.props.plugin.call('terminal', 'log', { type: 'aitypewriterwarning', value: 'Solcoder - generating code for following comment: ' + ask.replace('///', '') })
6767

6868
const data = await this.props.plugin.call('solcoder', 'code_generation', word)
69-
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_generation'])
7069

7170
const parsedData = data[0].trimStart() //JSON.parse(data).trimStart()
7271
const item: monacoTypes.languages.InlineCompletion = {
@@ -105,7 +104,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
105104
// Code insertion
106105
try {
107106
const output = await this.props.plugin.call('solcoder', 'code_insertion', word, word_after)
108-
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_insertion'])
109107
const generatedText = output[0] // no need to clean it. should already be
110108

111109
const item: monacoTypes.languages.InlineCompletion = {
@@ -130,7 +128,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
130128
try {
131129
// Code completion
132130
const output = await this.props.plugin.call('solcoder', 'code_completion', word)
133-
_paq.push(['trackEvent', 'ai', 'solcoder', 'code_completion'])
134131
const generatedText = output[0]
135132
let clean = generatedText
136133

0 commit comments

Comments
 (0)