From 53954e4c05b4c966232b22a18796ca495cdd541a Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 6 Oct 2024 16:14:12 -0700 Subject: [PATCH] feat: ask floating button --- .../chat/Messages/ContentRenderer.svelte | 134 +++++++++++++++--- .../chat/Messages/ResponseMessage.svelte | 24 ++-- 2 files changed, 130 insertions(+), 28 deletions(-) diff --git a/src/lib/components/chat/Messages/ContentRenderer.svelte b/src/lib/components/chat/Messages/ContentRenderer.svelte index f815eb5df..69010dc49 100644 --- a/src/lib/components/chat/Messages/ContentRenderer.svelte +++ b/src/lib/components/chat/Messages/ContentRenderer.svelte @@ -1,10 +1,12 @@
@@ -87,23 +123,83 @@ {#if floatingButtons} + {:else} +
+ { + if (e.key === 'Enter') { + selectAskHandler(); + } + }} + /> + +
+ +
+
+ {/if}
{/if} diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 7d5e496d3..73d407085 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -490,15 +490,21 @@ dispatch('update'); }} - on:explain={(e) => { - dispatch('submit', { - parentId: message.id, - prompt: - `Explain this section to me in more detail\n\n` + - '```\n' + - e.detail + - '\n```' - }); + on:select={(e) => { + const { type, content } = e.detail; + + if (type === 'explain') { + dispatch('submit', { + parentId: message.id, + prompt: `Explain this section to me in more detail\n\n\`\`\`\n${content}\n\`\`\`` + }); + } else if (type === 'ask') { + const input = e.detail?.input ?? ''; + dispatch('submit', { + parentId: message.id, + prompt: `\`\`\`\n${content}\n\`\`\`\n${input}` + }); + } }} /> {/if}