fixed typewriterwarning conflict

pull/4650/head
Stéphane Tetsing 11 months ago
parent ba88779e41
commit 37d266d128
  1. 18
      apps/remix-ide/src/app/plugins/solcoderAI.tsx
  2. 2
      libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts
  3. 9
      libs/remix-ui/terminal/src/lib/reducers/terminalReducer.ts
  4. 1
      libs/remix-ui/terminal/src/lib/types/terminalTypes.ts

@ -32,7 +32,7 @@ export class SolCoder extends Plugin {
async code_generation(prompt): Promise<any> { async code_generation(prompt): Promise<any> {
this.emit("aiInfering") this.emit("aiInfering")
this.call('layout', 'maximizeTerminal') this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', { type: 'typewriterwarning', value: 'Code Generation: Waiting for Solcoder answer...'}) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: 'Code Generation: Waiting for Solcoder answer...'})
let result let result
try { try {
result = await( result = await(
@ -47,7 +47,7 @@ export class SolCoder extends Plugin {
).json() ).json()
console.log(result) console.log(result)
if ("error" in result){ if ("error" in result){
this.call('terminal', 'log', { type: 'typewriterwarning', value: result.error }) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.error })
return result return result
} }
return result.data return result.data
@ -62,7 +62,7 @@ export class SolCoder extends Plugin {
async solidity_answer(prompt): Promise<any> { async solidity_answer(prompt): Promise<any> {
this.emit("aiInfering") this.emit("aiInfering")
this.call('layout', 'maximizeTerminal') this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', { type: 'typewriterwarning', value: 'Waiting for Solcoder answer...'}) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: 'Waiting for Solcoder answer...'})
let result let result
try { try {
result = await( result = await(
@ -82,9 +82,9 @@ export class SolCoder extends Plugin {
this.emit("aiInferingDone") this.emit("aiInferingDone")
} }
if (result) { if (result) {
this.call('terminal', 'log', { type: 'typewriterwarning', value: result.data[0]}) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0]})
} else if (result.error) { } else if (result.error) {
this.call('terminal', 'log', { type: 'typewriterwarning', value: "Error on request" }) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "Error on request" })
} }
} }
@ -92,7 +92,7 @@ export class SolCoder extends Plugin {
async code_explaining(prompt): Promise<any> { async code_explaining(prompt): Promise<any> {
this.emit("aiInfering") this.emit("aiInfering")
this.call('layout', 'maximizeTerminal') this.call('layout', 'maximizeTerminal')
this.call('terminal', 'log', { type: 'typewriterwarning', value: 'Explain Code: Waiting for Solcoder answer...'}) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: 'Explain Code: Waiting for Solcoder answer...'})
let result let result
try { try {
result = await( result = await(
@ -106,7 +106,7 @@ export class SolCoder extends Plugin {
}) })
).json() ).json()
if (result) { if (result) {
this.call('terminal', 'log', { type: 'typewriterwarning', value: result.data[0]}) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0]})
} }
return result.data[0] return result.data[0]
} catch (e) { } catch (e) {
@ -151,13 +151,13 @@ export class SolCoder extends Plugin {
).json() ).json()
if ("error" in result){ if ("error" in result){
this.call('terminal', 'log', { type: 'typewriterwarning', value: result.error }) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.error })
return result return result
} }
return result.data return result.data
} catch (e) { } catch (e) {
this.call('terminal', 'log', { type: 'typewriterwarning', value: `Unable to get a response ${e.message}` }) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: `Unable to get a response ${e.message}` })
return return
} finally { } finally {
this.emit("aiInferingDone") this.emit("aiInferingDone")

@ -52,7 +52,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli
const ask = split[split.length - 2].trimStart() const ask = split[split.length - 2].trimStart()
if (split[split.length - 1].trim() === '' && ask.startsWith('///')) { if (split[split.length - 1].trim() === '' && ask.startsWith('///')) {
// use the code generation model, only take max 1000 word as context // use the code generation model, only take max 1000 word as context
this.props.plugin.call('terminal', 'log', {type: 'typewriterwarning', value: 'Solcoder - generating code for following comment: ' + ask.replace('///', '')}) this.props.plugin.call('terminal', 'log', {type: 'aitypewriterwarning', value: 'Solcoder - generating code for following comment: ' + ask.replace('///', '')})
const data = await this.props.plugin.call('solcoder', 'code_generation', word) const data = await this.props.plugin.call('solcoder', 'code_generation', word)

@ -1,4 +1,4 @@
import { CLEAR_CONSOLE, CMD_HISTORY, EMPTY_BLOCK, ERROR, HTML, INFO, KNOWN_TRANSACTION, LISTEN_ON_NETWORK, LOG, TYPEWRITERLOG, TYPEWRITERWARNING, TYPEWRITERSUCCESS, NEW_TRANSACTION, SCRIPT, UNKNOWN_TRANSACTION, WARN } from '../types/terminalTypes' import { CLEAR_CONSOLE, CMD_HISTORY, EMPTY_BLOCK, ERROR, HTML, INFO, KNOWN_TRANSACTION, LISTEN_ON_NETWORK, LOG, TYPEWRITERLOG, TYPEWRITERWARNING, AITYPEWRITERWARNING, TYPEWRITERSUCCESS, NEW_TRANSACTION, SCRIPT, UNKNOWN_TRANSACTION, WARN } from '../types/terminalTypes'
export const initialState = { export const initialState = {
journalBlocks: [ journalBlocks: [
@ -156,11 +156,16 @@ export const registerScriptRunnerReducer = (state, action) => {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, typewriter: true, style: 'text-log', provider: action.payload.provider }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, typewriter: true, style: 'text-log', provider: action.payload.provider })
} }
case TYPEWRITERWARNING: case AITYPEWRITERWARNING:
return { return {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, typewriter: true, style: 'text-ai', provider: action.payload.provider }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, typewriter: true, style: 'text-ai', provider: action.payload.provider })
} }
case TYPEWRITERWARNING:
return {
...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, typewriter: true, style: 'text-warning', provider: action.payload.provider })
}
case TYPEWRITERSUCCESS: case TYPEWRITERSUCCESS:
return { return {
...state, ...state,

@ -17,6 +17,7 @@ export const HTML = 'html'
export const LOG = 'log' export const LOG = 'log'
export const TYPEWRITERLOG = 'typewriterlog' export const TYPEWRITERLOG = 'typewriterlog'
export const TYPEWRITERWARNING = 'typewriterwarning' export const TYPEWRITERWARNING = 'typewriterwarning'
export const AITYPEWRITERWARNING = 'aitypewriterwarning'
export const TYPEWRITERSUCCESS = 'typewritersuccess' export const TYPEWRITERSUCCESS = 'typewritersuccess'
export const INFO = 'info' export const INFO = 'info'
export const WARN = 'warn' export const WARN = 'warn'

Loading…
Cancel
Save