fixed in comment completion and added processing spinner

inlinecompletion_update
Stéphane Tetsing 9 months ago
parent 087833a064
commit 9fb0d5d4bf
  1. 11
      apps/remix-ide/src/app/plugins/solcoderAI.tsx
  2. 12
      libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts
  3. 14
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx

@ -20,6 +20,7 @@ export class SolCoder extends Plugin {
}
async code_generation(prompt): Promise<any> {
this.emit("aiInfering")
this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', 'Waiting for Solcoder answer...')
let result
@ -34,14 +35,17 @@ export class SolCoder extends Plugin {
body: JSON.stringify({"data":[prompt,false,1000,0.2,0.8,50]}),
})
).json()
return result.data[0]
return result.data[0]
} catch (e) {
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` })
return
}finally {
this.emit("aiInferingDone")
}
}
async solidity_answer(prompt): Promise<any> {
this.emit("aiInfering")
this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', 'Waiting for Solcoder answer...')
let result
@ -59,6 +63,8 @@ export class SolCoder extends Plugin {
} catch (e) {
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` })
return
}finally {
this.emit("aiInferingDone")
}
if (result) {
this.call('terminal', 'log', { type: 'typewriterwarning', value: result.data[0]})
@ -70,6 +76,7 @@ export class SolCoder extends Plugin {
async code_completion(prompt, options:SuggestOptions=null): Promise<any> {
this.emit("aiInfering")
let result
try {
result = await(
@ -103,6 +110,8 @@ export class SolCoder extends Plugin {
} catch (e) {
this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` })
return
} finally {
this.emit("aiInferingDone")
}
}

@ -2,6 +2,8 @@
import { EditorUIProps, monacoTypes } from '@remix-ui/editor';
import axios, {AxiosResponse} from 'axios'
import { slice } from 'lodash';
const _paq = (window._paq = window._paq || [])
const controller = new AbortController();
const { signal } = controller;
const result: string = ''
@ -27,6 +29,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
endLineNumber: position.lineNumber,
endColumn: position.column,
});
if (!word.endsWith(' ') &&
!word.endsWith('\n') &&
@ -65,6 +68,15 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
} catch (e) {
console.error(e)
}
if (word.split('\n').at(-1).trimStart().startsWith('//') ||
word.split('\n').at(-1).trimStart().startsWith('/*') ||
word.split('\n').at(-1).trimStart().startsWith('*') ||
word.split('\n').at(-1).trimStart().startsWith('*/')
){
return; // do not do completion on single and multiline comment
}
// abort if there is a signal
if (token.isCancellationRequested) {

@ -44,6 +44,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const [cmdHistory, cmdHistoryDispatch] = useReducer(addCommandHistoryReducer, initialState)
const [, scriptRunnerDispatch] = useReducer(registerScriptRunnerReducer, initialState)
const [toaster, setToaster] = useState(false)
const [aiLoading, setAILoading] = useState(false)
const [toastProvider, setToastProvider] = useState({
show: false,
fileName: '',
@ -103,6 +104,14 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
setIsVM(provider.startsWith('vm-'))
})
props.plugin.on('solcoder', 'aiInfering', () => {
setAILoading(true)
})
props.plugin.on('solcoder', 'aiInferingDone', () => {
setAILoading(false)
})
props.onReady({
logHtml: (html) => {
scriptRunnerDispatch({
@ -649,6 +658,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
data-id="terminalInputSearch"
/>
</div>
{aiLoading && <div className="text-center py-5 ml-5">
<i className="fas fa-spinner fa-pulse fa-2x"></i>
<span className="position-absolute">AI Running</span>
</div>}
</div>
</div>
<div tabIndex={-1} className="remix_ui_terminal_container d-flex h-100 m-0 flex-column" data-id="terminalContainer">

Loading…
Cancel
Save