added chat on all terminal interactions

pull/4884/head
Stéphane Tetsing 5 months ago committed by Aniket
parent b6dd45bc63
commit 50814f91a3
  1. 12
      apps/remix-ide/src/app/plugins/solcoderAI.tsx
  2. 2
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx

@ -47,6 +47,12 @@ export class SolCoder extends Plugin {
this.solgpt_chat_history = [] this.solgpt_chat_history = []
} }
pushChatHistory(prompt, result){
const chat:ChatEntry = [prompt, result.data[0]]
this.solgpt_chat_history.push(chat)
if (this.solgpt_chat_history.length >this.max_history){this.solgpt_chat_history.shift()}
}
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')
@ -105,9 +111,7 @@ export class SolCoder extends Plugin {
} }
if (result) { if (result) {
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] }) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] })
const chat:ChatEntry = [prompt, result.data[0]] this.pushChatHistory(prompt, result)
this.solgpt_chat_history.push(chat)
if (this.solgpt_chat_history.length >this.max_history){this.solgpt_chat_history.shift()}
} else if (result.error) { } else if (result.error) {
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "Error on request" }) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "Error on request" })
} }
@ -134,6 +138,7 @@ export class SolCoder extends Plugin {
).json() ).json()
if (result) { if (result) {
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] }) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] })
this.pushChatHistory(prompt, result)
} }
return result.data[0] return result.data[0]
} catch (e) { } catch (e) {
@ -250,6 +255,7 @@ export class SolCoder extends Plugin {
).json() ).json()
if (result) { if (result) {
this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] }) this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] })
this.pushChatHistory(prompt, result)
} }
return result.data[0] return result.data[0]
} catch (e) { } catch (e) {

@ -744,7 +744,7 @@ export const EditorUI = (props: EditorUIProps) => {
const range = new monacoRef.current.Range(cln.start.line, cln.start.column, cln.start.line, cln.start.column) const range = new monacoRef.current.Range(cln.start.line, cln.start.column, cln.start.line, cln.start.column)
const lines = natspecCom.split('\n') const lines = natspecCom.split('\n')
const newnatspeccom = [] //natspecCom.split('\n').map((line => ' '.repeat(cln.start.column) + line.trimStart())).join('\n') const newnatspeccom = []
for (let i = 0; i < lines.length; i++) { for (let i = 0; i < lines.length; i++) {
let cont = false let cont = false

Loading…
Cancel
Save