From 2c122d2a33567dcaace93e4cc79fa3e937ab80b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Tetsing?= Date: Tue, 11 Jun 2024 13:04:46 +0200 Subject: [PATCH] added chat on all terminal interactions --- apps/remix-ide/src/app/plugins/solcoderAI.tsx | 12 +++++++++--- libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/solcoderAI.tsx b/apps/remix-ide/src/app/plugins/solcoderAI.tsx index 81478a40be..82eedb3e29 100644 --- a/apps/remix-ide/src/app/plugins/solcoderAI.tsx +++ b/apps/remix-ide/src/app/plugins/solcoderAI.tsx @@ -47,6 +47,12 @@ export class SolCoder extends Plugin { 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 { this.emit("aiInfering") this.call('layout', 'maximizeTerminal') @@ -105,9 +111,7 @@ export class SolCoder extends Plugin { } if (result) { this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] }) - 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()} + this.pushChatHistory(prompt, result) } else if (result.error) { this.call('terminal', 'log', { type: 'aitypewriterwarning', value: "Error on request" }) } @@ -134,6 +138,7 @@ export class SolCoder extends Plugin { ).json() if (result) { this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] }) + this.pushChatHistory(prompt, result) } return result.data[0] } catch (e) { @@ -250,6 +255,7 @@ export class SolCoder extends Plugin { ).json() if (result) { this.call('terminal', 'log', { type: 'aitypewriterwarning', value: result.data[0] }) + this.pushChatHistory(prompt, result) } return result.data[0] } catch (e) { diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index d77108c1ad..78f18b5e81 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -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 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++) { let cont = false