diff --git a/apps/remix-ide/src/app/plugins/solcoderAI.tsx b/apps/remix-ide/src/app/plugins/solcoderAI.tsx index 9b2d3f81dc..be5cb2cb93 100644 --- a/apps/remix-ide/src/app/plugins/solcoderAI.tsx +++ b/apps/remix-ide/src/app/plugins/solcoderAI.tsx @@ -15,7 +15,7 @@ const profile = { name: 'solcoder', displayName: 'solcoder', description: 'solcoder', - methods: ['code_generation', 'code_completion', "solidity_answer", "code_explaining", "code_insertion"], + methods: ['code_generation', 'code_completion', "solidity_answer", "code_explaining", "code_insertion", "contract_generation"], events: [], maintainedBy: 'Remix', } @@ -219,12 +219,12 @@ export class SolCoder extends Plugin { } } - async contract_genertion(prompt): Promise { + async contract_generation(prompt): Promise { this.emit("aiInfering") let result try { result = await( - await fetch(this.completion_url, { + await fetch(this.api_url, { method: 'POST', headers: { Accept: 'application/json', @@ -255,7 +255,6 @@ export class SolCoder extends Plugin { } } - _build_solgpt_promt(user_promt:string){ if (this.solgpt_chat_history.length === 0){ return user_promt diff --git a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts index 825a01abbe..4ce3dd83cc 100644 --- a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts @@ -46,6 +46,28 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli endColumn: getTextAtLine(model.getLineCount()).length + 1, }); + if (this.isSolidityComment(word) && + word.includes("sol-gen") && + this.isGeneratingContract===false && + word.split('\n')[word.split('\n').length-1].trim()===""){ + + this.isGeneratingContract = true + console.log("new contract generation") + const output = await this.props.plugin.call('solcoder', 'contract_generation', word) + _paq.push(['trackEvent', 'ai', 'solcoder', 'contract_generation']) + const handleCompletionTimer = new CompletionTimer(5000, () => { this.isGeneratingContract = false }); + handleCompletionTimer.start() + + const item: monacoTypes.languages.InlineCompletion = { + insertText: output[0] + }; + + return { + items: [item], + enableForwardStability: true + } + } + if (!word.endsWith(' ') && !word.endsWith('.') && !word.endsWith('(')) { @@ -85,25 +107,6 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli return } - console.log("is sol comment", this.isSolidityComment(word)) - if (this.isSolidityComment(word) && word.includes("sol-gen") && this.isGeneratingContract===false){ - this.isGeneratingContract = true - console.log("new contract generation") - const output = await this.props.plugin.call('solcoder', 'contract_generation', word) - _paq.push(['trackEvent', 'ai', 'solcoder', 'contract_generation']) - const handleCompletionTimer = new CompletionTimer(5000, () => { this.isGeneratingContract = false }); - handleCompletionTimer.start() - - const item: monacoTypes.languages.InlineCompletion = { - insertText: output[0] - }; - - return { - items: [item], - enableForwardStability: true - } - } - if (word.split('\n').at(-1).trimStart().startsWith('//') || word.split('\n').at(-1).trimStart().startsWith('/*') || word.split('\n').at(-1).trimStart().startsWith('*') ||