Merge pull request #4286 from ethereum/copilotImprove

Solidity copilot improvements
pull/4288/head
yann300 1 year ago committed by GitHub
commit 64b4d78309
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts
  2. 8
      apps/remix-ide/src/app/plugins/copilot/suggestion-service/suggestion-service.ts
  3. 2
      apps/remix-ide/src/app/tabs/locales/en/settings.json
  4. 7
      libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts
  5. 6
      libs/remix-ui/settings/src/lib/remix-ui-settings.tsx

@ -5,8 +5,10 @@ const _paq = (window._paq = window._paq || []) //eslint-disable-line
const profile = {
name: 'copilot-suggestion',
displayName: 'copilot-suggestion',
description: 'copilot-suggestion',
methods: ['suggest', 'init', 'uninstall', 'status', 'isActivate']
description: 'Get Solidity suggestions in editor',
methods: ['suggest', 'init', 'uninstall', 'status', 'isActivate'],
version: '0.1.0-alpha',
maintainedBy: "Remix"
}
export class CopilotSuggestion extends Plugin {
@ -45,7 +47,6 @@ export class CopilotSuggestion extends Plugin {
const max_new_tokens = await this.call('settings', 'get', 'settings/copilot/suggest/max_new_tokens')
const temperature = await this.call('settings', 'get', 'settings/copilot/suggest/temperature')
console.log('suggest', max_new_tokens, temperature)
const options: SuggestOptions = {
do_sample: false,
top_k: 0,

@ -28,37 +28,31 @@ export class SuggestionService {
const onMessageReceived = (e) => {
switch (e.data.status) {
case 'initiate':
console.log(e.data)
this.events.emit(e.data.status, e.data)
// Model file start load: add a new progress item to the list.
break;
case 'progress':
this.events.emit(e.data.status, e.data)
console.log(e.data)
// Model file progress: update one of the progress items.
break;
case 'done':
this.events.emit(e.data.status, e.data)
console.log(e.data)
// Model file loaded: remove the progress item from the list.
break;
case 'ready':
this.events.emit(e.data.status, e.data)
console.log(e.data)
// Pipeline ready: the worker is ready to accept messages.
break;
case 'update':
this.events.emit(e.data.status, e.data)
console.log(e.data)
// Generation update: update the output text.
break;
case 'complete':
console.log(e.data)
if (this.responses[e.data.id]) {
if (this.current === e.data.id) {
this.responses[e.data.id](null, e.data)
@ -67,8 +61,6 @@ export class SuggestionService {
}
delete this.responses[e.data.id]
this.current = null
} else {
console.log('no callback for', e.data)
}
// Generation complete: re-enable the "Generate" button

@ -39,6 +39,6 @@
"settings.analyticsInRemix": "Analytics in Remix IDE",
"settings.copilot": "Solidity copilot - Alpha",
"settings.copilot.activate": "Load & Activate copilot",
"settings.copilot.max_new_tokens": "Maximum amount of new words to generate",
"settings.copilot.max_new_tokens": "Maximum number of words to generate",
"settings.copilot.temperature": "Temperature"
}

@ -15,7 +15,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
async provideInlineCompletions(model: monacoTypes.editor.ITextModel, position: monacoTypes.Position, context: monacoTypes.languages.InlineCompletionContext, token: monacoTypes.CancellationToken): Promise<monacoTypes.languages.InlineCompletions<monacoTypes.languages.InlineCompletion>> {
if (context.selectedSuggestionInfo) {
console.log('return empty from provideInlineCompletions')
return;
}
// get text before the position of the completion
@ -27,7 +26,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
});
if (!word.endsWith(' ') && !word.endsWith('\n') && !word.endsWith(';') && !word.endsWith('.')) {
console.log('not a trigger char')
return;
}
@ -40,13 +38,12 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
try {
const split = word.split('\n')
if (!split.length) return
if (split.length < 2) return
const ask = split[split.length - 2].trimStart()
if (split[split.length - 1].trim() === '' && ask.startsWith('///')) {
// use the code generation model
const {data} = await axios.post('https://gpt-chat.remixproject.org/infer', {comment: ask.replace('///', '')})
const parsedData = JSON.parse(data).trimStart()
console.log('parsedData', parsedData)
const item: monacoTypes.languages.InlineCompletion = {
insertText: parsedData
};
@ -61,7 +58,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
// abort if there is a signal
if (token.isCancellationRequested) {
console.log('aborted')
return
}
@ -81,7 +77,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
// abort if there is a signal
if (token.isCancellationRequested) {
console.log('aborted')
return
}
return {

@ -144,7 +144,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
})
const modalActivate: AppModal = {
id: 'loadcopilotActivate',
title: 'Downloading Solidity copilot',
title: 'Download Solidity copilot',
modalType: ModalTypes.default,
okLabel: 'Close',
message,
@ -466,7 +466,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
<div className="text-secondary mb-0 h6">
<div>
<div className="mb-1">
<label className={`align-middle ${getTextClass('settings/copilot/suggest/max_new_tokens')}`} htmlFor="copilot-activate">
<label className={`form-check-label align-middle ${getTextClass('settings/copilot/suggest/max_new_tokens')}`} htmlFor="copilot-activate">
<FormattedMessage id="settings.copilot.max_new_tokens" /> - <span>{copilotMaxnewToken}</span>
</label>
<input onChange={onchangeCopilotMaxNewToken} id="copilot-max-new-token" value={copilotMaxnewToken} min='1' max='150' type="range" className="custom-range" />
@ -479,7 +479,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
<div className="text-secondary mb-0 h6">
<div>
<div className="mb-1">
<label className={`align-middle ${getTextClass('settings/copilot/suggest/temperature')}`} htmlFor="copilot-activate">
<label className={`form-check-label align-middle ${getTextClass('settings/copilot/suggest/temperature')}`} htmlFor="copilot-activate">
<FormattedMessage id="settings.copilot.temperature" /> - <span>{copilotTemperatureValue / 100}</span>
</label>
<input onChange={onchangeCopilotTemperature} id="copilot-temperature" value={copilotTemperatureValue} min='0' max='100' type="range" className="custom-range" />

Loading…
Cancel
Save