diff --git a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx index f16ffacebd..aad61e2a0f 100644 --- a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx +++ b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx @@ -112,11 +112,11 @@ export class RemixAIPlugin extends ViewPlugin { } } - async code_completion(prompt: string): Promise { + async code_completion(prompt: string, promptAfter: string): Promise { if (this.isOnDesktop) { return await this.call(this.remixDesktopPluginName, 'code_completion', prompt) } else { - return await this.remoteInferencer.code_completion(prompt) + return await this.remoteInferencer.code_completion(prompt, promptAfter) } } diff --git a/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts b/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts index 3bbfc173af..f618133a0f 100644 --- a/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts +++ b/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts @@ -110,19 +110,17 @@ export class RemoteInferencer implements ICompletions { } } - async code_completion(prompt, options:IParams=CompletionParams): Promise { - const payload = { prompt, "endpoint":"code_completion", ...options } + async code_completion(prompt, promptAfter, options:IParams=CompletionParams): Promise { + const payload = { prompt, 'context':promptAfter, "endpoint":"code_completion", ...options } return this._makeRequest(payload, AIRequestType.COMPLETION) } async code_insertion(msg_pfx, msg_sfx, options:IParams=InsertionParams): Promise { - // const payload = { "data":[msg_pfx, "code_insertion", msg_sfx, 1024, 0.5, 0.92, 50]} const payload = { "endpoint":"code_insertion", msg_pfx, msg_sfx, ...options, prompt: '' } return this._makeRequest(payload, AIRequestType.COMPLETION) } async code_generation(prompt, options:IParams=GenerationParams): Promise { - // const payload = { "data":[prompt, "code_completion", "", false,1000,0.9,0.92,50]} const payload = { prompt, "endpoint":"code_completion", ...options } if (options.stream_result) return this._streamInferenceRequest(payload.endpoint, payload, AIRequestType.COMPLETION) else return this._makeRequest(payload, AIRequestType.COMPLETION) @@ -130,14 +128,12 @@ export class RemoteInferencer implements ICompletions { async solidity_answer(prompt, options:IParams=GenerationParams): Promise { const main_prompt = buildSolgptPromt(prompt, this.model_op) - // const payload = { "data":[main_prompt, "solidity_answer", false,2000,0.9,0.8,50]} const payload = { 'prompt': main_prompt, "endpoint":"solidity_answer", ...options } if (options.stream_result) return this._streamInferenceRequest(payload.endpoint, payload, AIRequestType.GENERAL) else return this._makeRequest(payload, AIRequestType.GENERAL) } async code_explaining(prompt, context:string="", options:IParams=GenerationParams): Promise { - // const payload = { "data":[prompt, "code_explaining", false,2000,0.9,0.8,50, context]} const payload = { prompt, "endpoint":"code_explaining", context, ...options } if (options.stream_result) return this._streamInferenceRequest(payload.endpoint, payload, AIRequestType.GENERAL) else return this._makeRequest(payload, AIRequestType.GENERAL) diff --git a/libs/remix-ai-core/src/types/remix-project.code-workspace b/libs/remix-ai-core/src/types/remix-project.code-workspace new file mode 100644 index 0000000000..596ef7a482 --- /dev/null +++ b/libs/remix-ai-core/src/types/remix-project.code-workspace @@ -0,0 +1,7 @@ +{ + "folders": [ + { + "path": "../../../.." + } + ] +} \ No newline at end of file diff --git a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts index 4a792bad4b..51790a8b02 100644 --- a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts @@ -1,6 +1,8 @@ /* eslint-disable no-control-regex */ import { EditorUIProps, monacoTypes } from '@remix-ui/editor'; import { JsonStreamParser } from '@remix/remix-ai-core'; +import * as monaco from 'monaco-editor'; + const _paq = (window._paq = window._paq || []) export class RemixInLineCompletionProvider implements monacoTypes.languages.InlineCompletionsProvider { @@ -26,9 +28,8 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli } async provideInlineCompletions(model: monacoTypes.editor.ITextModel, position: monacoTypes.Position, context: monacoTypes.languages.InlineCompletionContext, token: monacoTypes.CancellationToken): Promise> { - if (context.selectedSuggestionInfo) { - return { items: []}; - } + const isActivate = await await this.props.plugin.call('settings', 'get', 'settings/copilot/suggest/activate') + if (!isActivate) return const currentTime = Date.now(); const timeSinceLastRequest = currentTime - this.lastRequestTime; @@ -65,13 +66,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli return; } - try { - const isActivate = await await this.props.plugin.call('settings', 'get', 'settings/copilot/suggest/activate') - if (!isActivate) return - } catch (err) { - return; - } - try { const split = word.split('\n') if (split.length < 2) return @@ -109,11 +103,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli return { items: []}; // do not do completion on single and multiline comment } - // abort if there is a signal - if (token.isCancellationRequested) { - return - } - if (word.replace(/ +$/, '').endsWith('\n')){ // Code insertion try { @@ -122,7 +111,8 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli this.task = 'code_insertion' const item: monacoTypes.languages.InlineCompletion = { - insertText: generatedText + insertText: generatedText, + range: new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column) }; this.currentCompletion.text = generatedText this.currentCompletion.item = item @@ -141,25 +131,26 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli try { // Code completion this.task = 'code_completion' - const output = await this.props.plugin.call('remixAI', 'code_completion', word) + const output = await this.props.plugin.call('remixAI', 'code_completion', word, word_after) const generatedText = output let clean = generatedText if (generatedText.indexOf('@custom:dev-run-script./') !== -1) { clean = generatedText.replace('@custom:dev-run-script', '@custom:dev-run-script ') } - clean = clean.replace(word, '').trimStart() + clean = clean.replace(word, '') clean = this.process_completion(clean) const item: monacoTypes.languages.InlineCompletion = { insertText: clean, + range: new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column) }; this.currentCompletion.text = clean this.currentCompletion.item = item return { items: [item], - enableForwardStability: true + enableForwardStability: false } } catch (err) { return @@ -174,7 +165,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli return "" } // remove comment inline - clean = clean.split('//')[0].trimEnd() + clean = clean.split('//')[0] return clean }