enforcing suggestion on editor

pull/5309/head
STetsing 1 month ago committed by Aniket
parent 35a92f31af
commit 2bdb6577fa
  1. 6
      apps/remix-ide/src/app/plugins/remixAIPlugin.tsx
  2. 16
      apps/remix-ide/src/assets/list.json
  3. 6
      libs/remix-ai-core/src/inferencers/remote/remoteInference.ts
  4. 13
      libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts

@ -87,11 +87,11 @@ export class RemixAIPlugin extends Plugin {
}
}
async code_completion(prompt: string): Promise<any> {
async code_completion(prompt: string, promptAfter: string): Promise<any> {
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)
}
}

@ -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"
}
"latestRelease": "0.8.28"
}

@ -103,10 +103,10 @@ export class RemoteInferencer implements ICompletions {
}
}
async code_completion(prompt, options:IParams=null): Promise<any> {
async code_completion(prompt, promptAfter, options:IParams=null): Promise<any> {
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]
}

@ -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

Loading…
Cancel
Save