Skip to content

Commit 64b4d78

Browse files
authored
Merge pull request #4286 from ethereum/copilotImprove
Solidity copilot improvements
2 parents a5e99c0 + bfd0159 commit 64b4d78

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

apps/remix-ide/src/app/plugins/copilot/suggestion-service/copilot-suggestion.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ const _paq = (window._paq = window._paq || []) //eslint-disable-line
55
const profile = {
66
name: 'copilot-suggestion',
77
displayName: 'copilot-suggestion',
8-
description: 'copilot-suggestion',
9-
methods: ['suggest', 'init', 'uninstall', 'status', 'isActivate']
8+
description: 'Get Solidity suggestions in editor',
9+
methods: ['suggest', 'init', 'uninstall', 'status', 'isActivate'],
10+
version: '0.1.0-alpha',
11+
maintainedBy: "Remix"
1012
}
1113

1214
export class CopilotSuggestion extends Plugin {
@@ -45,7 +47,6 @@ export class CopilotSuggestion extends Plugin {
4547

4648
const max_new_tokens = await this.call('settings', 'get', 'settings/copilot/suggest/max_new_tokens')
4749
const temperature = await this.call('settings', 'get', 'settings/copilot/suggest/temperature')
48-
console.log('suggest', max_new_tokens, temperature)
4950
const options: SuggestOptions = {
5051
do_sample: false,
5152
top_k: 0,

apps/remix-ide/src/app/plugins/copilot/suggestion-service/suggestion-service.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,31 @@ export class SuggestionService {
2828
const onMessageReceived = (e) => {
2929
switch (e.data.status) {
3030
case 'initiate':
31-
console.log(e.data)
3231
this.events.emit(e.data.status, e.data)
3332
// Model file start load: add a new progress item to the list.
3433
break;
3534

3635
case 'progress':
3736
this.events.emit(e.data.status, e.data)
38-
console.log(e.data)
3937
// Model file progress: update one of the progress items.
4038
break;
4139

4240
case 'done':
4341
this.events.emit(e.data.status, e.data)
44-
console.log(e.data)
4542
// Model file loaded: remove the progress item from the list.
4643
break;
4744

4845
case 'ready':
4946
this.events.emit(e.data.status, e.data)
50-
console.log(e.data)
5147
// Pipeline ready: the worker is ready to accept messages.
5248
break;
5349

5450
case 'update':
5551
this.events.emit(e.data.status, e.data)
56-
console.log(e.data)
5752
// Generation update: update the output text.
5853
break;
5954

6055
case 'complete':
61-
console.log(e.data)
6256
if (this.responses[e.data.id]) {
6357
if (this.current === e.data.id) {
6458
this.responses[e.data.id](null, e.data)
@@ -67,8 +61,6 @@ export class SuggestionService {
6761
}
6862
delete this.responses[e.data.id]
6963
this.current = null
70-
} else {
71-
console.log('no callback for', e.data)
7264
}
7365

7466
// Generation complete: re-enable the "Generate" button

apps/remix-ide/src/app/tabs/locales/en/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@
3939
"settings.analyticsInRemix": "Analytics in Remix IDE",
4040
"settings.copilot": "Solidity copilot - Alpha",
4141
"settings.copilot.activate": "Load & Activate copilot",
42-
"settings.copilot.max_new_tokens": "Maximum amount of new words to generate",
42+
"settings.copilot.max_new_tokens": "Maximum number of words to generate",
4343
"settings.copilot.temperature": "Temperature"
4444
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
1515

1616
async provideInlineCompletions(model: monacoTypes.editor.ITextModel, position: monacoTypes.Position, context: monacoTypes.languages.InlineCompletionContext, token: monacoTypes.CancellationToken): Promise<monacoTypes.languages.InlineCompletions<monacoTypes.languages.InlineCompletion>> {
1717
if (context.selectedSuggestionInfo) {
18-
console.log('return empty from provideInlineCompletions')
1918
return;
2019
}
2120
// get text before the position of the completion
@@ -27,7 +26,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
2726
});
2827

2928
if (!word.endsWith(' ') && !word.endsWith('\n') && !word.endsWith(';') && !word.endsWith('.')) {
30-
console.log('not a trigger char')
3129
return;
3230
}
3331

@@ -40,13 +38,12 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
4038

4139
try {
4240
const split = word.split('\n')
43-
if (!split.length) return
41+
if (split.length < 2) return
4442
const ask = split[split.length - 2].trimStart()
4543
if (split[split.length - 1].trim() === '' && ask.startsWith('///')) {
4644
// use the code generation model
4745
const {data} = await axios.post('https://gpt-chat.remixproject.org/infer', {comment: ask.replace('///', '')})
4846
const parsedData = JSON.parse(data).trimStart()
49-
console.log('parsedData', parsedData)
5047
const item: monacoTypes.languages.InlineCompletion = {
5148
insertText: parsedData
5249
};
@@ -61,7 +58,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
6158

6259
// abort if there is a signal
6360
if (token.isCancellationRequested) {
64-
console.log('aborted')
6561
return
6662
}
6763

@@ -81,7 +77,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
8177

8278
// abort if there is a signal
8379
if (token.isCancellationRequested) {
84-
console.log('aborted')
8580
return
8681
}
8782
return {

libs/remix-ui/settings/src/lib/remix-ui-settings.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
144144
})
145145
const modalActivate: AppModal = {
146146
id: 'loadcopilotActivate',
147-
title: 'Downloading Solidity copilot',
147+
title: 'Download Solidity copilot',
148148
modalType: ModalTypes.default,
149149
okLabel: 'Close',
150150
message,
@@ -466,7 +466,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
466466
<div className="text-secondary mb-0 h6">
467467
<div>
468468
<div className="mb-1">
469-
<label className={`align-middle ${getTextClass('settings/copilot/suggest/max_new_tokens')}`} htmlFor="copilot-activate">
469+
<label className={`form-check-label align-middle ${getTextClass('settings/copilot/suggest/max_new_tokens')}`} htmlFor="copilot-activate">
470470
<FormattedMessage id="settings.copilot.max_new_tokens" /> - <span>{copilotMaxnewToken}</span>
471471
</label>
472472
<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) => {
479479
<div className="text-secondary mb-0 h6">
480480
<div>
481481
<div className="mb-1">
482-
<label className={`align-middle ${getTextClass('settings/copilot/suggest/temperature')}`} htmlFor="copilot-activate">
482+
<label className={`form-check-label align-middle ${getTextClass('settings/copilot/suggest/temperature')}`} htmlFor="copilot-activate">
483483
<FormattedMessage id="settings.copilot.temperature" /> - <span>{copilotTemperatureValue / 100}</span>
484484
</label>
485485
<input onChange={onchangeCopilotTemperature} id="copilot-temperature" value={copilotTemperatureValue} min='0' max='100' type="range" className="custom-range" />

0 commit comments

Comments
 (0)