From 2bdb6577faf564498f3f53ba4f5516908bef3c30 Mon Sep 17 00:00:00 2001 From: STetsing <41009393+STetsing@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:11:15 +0200 Subject: [PATCH] enforcing suggestion on editor --- apps/remix-ide/src/app/plugins/remixAIPlugin.tsx | 6 +++--- apps/remix-ide/src/assets/list.json | 16 ++++++++++++++-- .../src/inferencers/remote/remoteInference.ts | 6 +++--- .../lib/providers/inlineCompletionProvider.ts | 13 ++++++++++--- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx index 312352cb46..8bc1427204 100644 --- a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx +++ b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx @@ -87,11 +87,11 @@ export class RemixAIPlugin extends Plugin { } } - 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) + return await this.call(this.remixDesktopPluginName, 'code_completion', prompt, promptAfter) } else { - return await this.remoteInferencer.code_completion(prompt) + return await this.remoteInferencer.code_completion(prompt, promptAfter) } } diff --git a/apps/remix-ide/src/assets/list.json b/apps/remix-ide/src/assets/list.json index 82f8fe17bb..6a47e64612 100644 --- a/apps/remix-ide/src/assets/list.json +++ b/apps/remix-ide/src/assets/list.json @@ -1033,9 +1033,21 @@ "urls": [ "dweb:/ipfs/QmVTALD1WUQwRvEL19jgwrEFyBJMQmy9z32zvT6TAtYPY1" ] + }, + { + "path": "soljson-v0.8.28+commit.7893614a.js", + "version": "0.8.28", + "build": "commit.7893614a", + "longVersion": "0.8.28+commit.7893614a", + "keccak256": "0x8e01bd0cafb8a8bab060453637101a88e4ab6d41c32645a26eaca541fb169c8e", + "sha256": "0x72ef580a6ec5943130028e5294313f24e9435520acc89f8c9dbfd0139d9ae146", + "urls": [ + "dweb:/ipfs/QmVtdNYdUC4aX6Uk5LrxDT55B7NgGLnLcA2wTecF5xUbSS" + ] } ], "releases": { + "0.8.28": "soljson-v0.8.28+commit.7893614a.js", "0.8.27": "soljson-v0.8.27+commit.40a35a09.js", "0.8.26": "soljson-v0.8.26+commit.8a97fa7a.js", "0.8.25": "soljson-v0.8.25+commit.b61c2a91.js", @@ -1131,5 +1143,5 @@ "0.4.0": "soljson-v0.4.0+commit.acd334c9.js", "0.3.6": "soljson-v0.3.6+commit.3fc68da5.js" }, - "latestRelease": "0.8.27" -} \ No newline at end of file + "latestRelease": "0.8.28" +} diff --git a/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts b/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts index 0c37cf751a..1c148bce22 100644 --- a/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts +++ b/libs/remix-ai-core/src/inferencers/remote/remoteInference.ts @@ -103,10 +103,10 @@ export class RemoteInferencer implements ICompletions { } } - async code_completion(prompt, options:IParams=null): Promise { + async code_completion(prompt, promptAfter, options:IParams=null): Promise { const payload = !options? - { "data": [prompt, "code_completion", "", false, 30, 0.9, 0.90, 50]} : - { "data": [prompt, "code_completion", "", options.stream_result, + { "data": [prompt, "code_completion", promptAfter, false, 30, 0.9, 0.90, 50]} : + { "data": [prompt, "code_completion", promptAfter, options.stream_result, options.max_new_tokens, options.temperature, options.top_p, options.top_k] } diff --git a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts index 79f995dd6e..37aaebd60b 100644 --- a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts @@ -1,5 +1,6 @@ /* eslint-disable no-control-regex */ import { EditorUIProps, monacoTypes } from '@remix-ui/editor'; +import * as monaco from 'monaco-editor'; const _paq = (window._paq = window._paq || []) export class RemixInLineCompletionProvider implements monacoTypes.languages.InlineCompletionsProvider { @@ -81,10 +82,12 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli const data = await this.props.plugin.call('remixAI', 'code_insertion', word, word_after) this.task = 'code_generation' + _paq.push(['trackEvent', 'ai', 'remixAI', 'code_generation']) const parsedData = data.trimStart() //JSON.parse(data).trimStart() const item: monacoTypes.languages.InlineCompletion = { - insertText: parsedData + insertText: parsedData, + range: new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column) }; this.currentCompletion.text = parsedData this.currentCompletion.item = item @@ -116,11 +119,13 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli // Code insertion try { const output = await this.props.plugin.call('remixAI', 'code_insertion', word, word_after) + _paq.push(['trackEvent', 'ai', 'remixAI', 'code_insertion']) const generatedText = output // no need to clean it. should already be 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 @@ -138,7 +143,8 @@ 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) + _paq.push(['trackEvent', 'ai', 'remixAI', 'code_completion']) const generatedText = output let clean = generatedText @@ -150,6 +156,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli 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