From 59ea0ac9aa8541430cab48ecb1d94f1e09c13856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Tetsing?= Date: Thu, 8 Feb 2024 17:45:35 +0100 Subject: [PATCH] disabled inline completion on comment --- apps/remix-ide/src/app/plugins/solcoderAI.tsx | 8 +++++--- .../editor/src/lib/providers/inlineCompletionProvider.ts | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/solcoderAI.tsx b/apps/remix-ide/src/app/plugins/solcoderAI.tsx index 298dcdde36..44fc8b43bd 100644 --- a/apps/remix-ide/src/app/plugins/solcoderAI.tsx +++ b/apps/remix-ide/src/app/plugins/solcoderAI.tsx @@ -13,8 +13,10 @@ const profile = { } export class SolCoder extends Plugin { + api_url: string constructor() { super(profile) + this.api_url = "https://hkfll35zthu6e2-7861.proxy.runpod.net/api/" } async code_generation(prompt): Promise { @@ -23,7 +25,7 @@ export class SolCoder extends Plugin { let result try { result = await( - await fetch("https://hkfll35zthu6e2-7861.proxy.runpod.net/api/code_generation", { + await fetch(this.api_url.concat("code_generation"), { method: 'POST', headers: { Accept: 'application/json', @@ -45,7 +47,7 @@ export class SolCoder extends Plugin { let result try { result = await( - await fetch("https://hkfll35zthu6e2-7861.proxy.runpod.net/api/solidity_answer", { + await fetch(this.api_url.concat("solidity_answer"), { method: 'POST', headers: { Accept: 'application/json', @@ -71,7 +73,7 @@ export class SolCoder extends Plugin { let result try { result = await( - await fetch("https://hkfll35zthu6e2-7861.proxy.runpod.net/api/code_completion", { + await fetch(this.api_url.concat("code_completion"), { method: 'POST', headers: { Accept: 'application/json', diff --git a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts index ad2fdb7440..263fb39a12 100644 --- a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts @@ -1,6 +1,7 @@ /* eslint-disable no-control-regex */ import { EditorUIProps, monacoTypes } from '@remix-ui/editor'; import axios, {AxiosResponse} from 'axios' +import { slice } from 'lodash'; const controller = new AbortController(); const { signal } = controller; const result: string = '' @@ -68,11 +69,15 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli let result try { - if (!this.running){ + if (word.split('\n').at(-1).trimStart().startsWith('//')){ + return // disable completion on comment -> current lie + }else if (!this.running){ + console.log('last line', word.split('\n').at(-1)) result = await this.props.plugin.call('copilot-suggestion', 'suggest', word) this.running = true } } catch (err) { + this.running=false return }