added gpt-sol and inline code completion

inlinecompletion_update
Stéphane Tetsing 10 months ago
parent fd5cab890d
commit ce953750e6
  1. 8
      apps/remix-ide/src/app.js
  2. 41
      apps/remix-ide/src/app/plugins/solcode_completion.tsx
  3. 77
      apps/remix-ide/src/app/plugins/solcoderAI.tsx
  4. 1
      apps/remix-ide/src/remixAppManager.js
  5. 1
      apps/remix-ide/src/remixEngine.js
  6. 5
      libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts
  7. 6
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx

@ -59,7 +59,7 @@ import { ripgrepPlugin } from './app/plugins/electron/ripgrepPlugin'
import { compilerLoaderPlugin, compilerLoaderPluginDesktop } from './app/plugins/electron/compilerLoaderPlugin' import { compilerLoaderPlugin, compilerLoaderPluginDesktop } from './app/plugins/electron/compilerLoaderPlugin'
import {OpenAIGpt} from './app/plugins/openaigpt' import {OpenAIGpt} from './app/plugins/openaigpt'
import {SolCodeComp} from './app/plugins/solcode_completion' import {SolCoder} from './app/plugins/solcoderAI'
const isElectron = require('is-electron') const isElectron = require('is-electron')
@ -234,7 +234,7 @@ class AppComponent {
// ----------------- AI -------------------------------------- // ----------------- AI --------------------------------------
const openaigpt = new OpenAIGpt() const openaigpt = new OpenAIGpt()
const solcodercomp = new SolCodeComp() const solcoder = new SolCoder()
const copilotSuggestion = new CopilotSuggestion() const copilotSuggestion = new CopilotSuggestion()
// ----------------- import content service ------------------------ // ----------------- import content service ------------------------
@ -362,7 +362,7 @@ class AppComponent {
solidityScript, solidityScript,
templates, templates,
openaigpt, openaigpt,
solcodercomp, solcoder,
copilotSuggestion copilotSuggestion
]) ])
@ -518,7 +518,7 @@ class AppComponent {
} }
) )
await this.appManager.activatePlugin(['solidity-script', 'openaigpt']) await this.appManager.activatePlugin(['solidity-script', 'openaigpt'])
await this.appManager.activatePlugin(['solcodercomp']) await this.appManager.activatePlugin(['solcoder'])

@ -1,41 +0,0 @@
import { Plugin } from '@remixproject/engine'
import { client } from "@gradio/client"
const _paq = (window._paq = window._paq || [])
const profile = {
name: 'solcoder_completion',
displayName: 'solcoder_completion',
description: 'solcoder_completion',
methods: ['message'],
events: [],
maintainedBy: 'Remix',
}
export class SolCodeComp extends Plugin {
constructor() {
super(profile)
}
async message(prompt): Promise<any> {
this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', 'Waiting for GPT answer...')
let result
try {
const app = await client("http://127.0.0.1:7860/", null);
const result = await app.predict("/code_completion", [
prompt, // string in 'context_code' Textbox component
"", // string in 'comment' Textbox component
false, // boolean in 'stream_result' Checkbox component
200, // number (numeric value between 0 and 2000) in 'max_new_tokens' Slider component
0.4, // number (numeric value between 0.01 and 1) in 'temperature' Slider component
0.90, // number (numeric value between 0 and 1) in 'top_p' Slider component
50, // number (numeric value between 1 and 200) in 'top_k' Slider component
]);
return result
} catch (e) {
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` })
return
}
}
}

@ -0,0 +1,77 @@
import { Plugin } from '@remixproject/engine'
const _paq = (window._paq = window._paq || [])
const profile = {
name: 'solcoder',
displayName: 'solcoder',
description: 'solcoder',
methods: ['code_generation', 'code_completion'],
events: [],
maintainedBy: 'Remix',
}
export class SolCoder extends Plugin {
constructor() {
super(profile)
}
async code_generation(prompt): Promise<any> {
this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', 'Waiting for Solcoder answer...')
let result
try {
result = await(
await fetch("https://hkfll35zthu6e2-7861.proxy.runpod.net/api/code_generation", {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({"data":[prompt,false,1000,0.2,0.8,50]}),
})
).json()
} catch (e) {
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` })
return
}
if (result) {
this.call('terminal', 'log', { type: 'typewriterwarning', value: result.data[0]})
} else if (result.error) {
this.call('terminal', 'log', { type: 'typewriterwarning', value: "Error on request" })
}
}
async code_completion(prompt): Promise<any> {
let result
try {
result = await(
await fetch("https://hkfll35zthu6e2-7861.proxy.runpod.net/api/code_completion", {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({"data":[
prompt, // string in 'context_code' Textbox component
"", // string in 'comment' Textbox component
false, // boolean in 'stream_result' Checkbox component
200, // number (numeric value between 0 and 2000) in 'max_new_tokens' Slider component
0.4, // number (numeric value between 0.01 and 1) in 'temperature' Slider component
0.90, // number (numeric value between 0 and 1) in 'top_p' Slider component
50, // number (numeric value between 1 and 200) in 'top_k' Slider component
]}),
})
).json()
console.log('solcoder result', result.data)
return result.data
} catch (e) {
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` })
return
}
}
}

@ -77,6 +77,7 @@ let requiredModules = [ // services + layout views + system views
'contractflattener', 'contractflattener',
'solidity-script', 'solidity-script',
'openaigpt', 'openaigpt',
'solcoder',
'home', 'home',
'doc-viewer', 'doc-viewer',
'doc-gen', 'doc-gen',

@ -26,6 +26,7 @@ export class RemixEngine extends Engine {
if (name === 'compilerloader') return { queueTimeout: 60000 * 4 } if (name === 'compilerloader') return { queueTimeout: 60000 * 4 }
if (name === 'filePanel') return { queueTimeout: 60000 * 20 } if (name === 'filePanel') return { queueTimeout: 60000 * 20 }
if (name === 'openaigpt') return { queueTimeout: 60000 * 2 } if (name === 'openaigpt') return { queueTimeout: 60000 * 2 }
if (name === 'solcoder') return { queueTimeout: 60000 * 2 }
if (name === 'cookbookdev') return { queueTimeout: 60000 * 2 } if (name === 'cookbookdev') return { queueTimeout: 60000 * 2 }
return { queueTimeout: 10000 } return { queueTimeout: 10000 }
} }

@ -43,8 +43,9 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
if (split[split.length - 1].trim() === '' && ask.startsWith('///')) { if (split[split.length - 1].trim() === '' && ask.startsWith('///')) {
// use the code generation model // use the code generation model
const {data} = await this.props.plugin.call('solcoder_completion', 'message', ask) const data = await this.props.plugin.call('solcoder', 'code_completion', word)
const parsedData = JSON.parse(data).trimStart() console.log("received solcoder data", data)
const parsedData = data[0].trimStart() //JSON.parse(data).trimStart()
const item: monacoTypes.languages.InlineCompletion = { const item: monacoTypes.languages.InlineCompletion = {
insertText: parsedData insertText: parsedData
}; };

@ -239,7 +239,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
call('terminal', 'log',{ type: 'warn', value: `> ${script}` }) call('terminal', 'log',{ type: 'warn', value: `> ${script}` })
await call('openaigpt', 'message', script) await call('openaigpt', 'message', script)
_paq.push(['trackEvent', 'ai', 'openai', 'askFromTerminal']) _paq.push(['trackEvent', 'ai', 'openai', 'askFromTerminal'])
} else { } else if (script.trim().startsWith('gpt-sol')) {
call('terminal', 'log',{ type: 'warn', value: `> ${script}` })
await call('solcoder', 'code_generation', script)
_paq.push(['trackEvent', 'ai', 'solcoder', 'askFromTerminal'])
}else {
await call('scriptRunner', 'execute', script) await call('scriptRunner', 'execute', script)
} }
done() done()

Loading…
Cancel
Save