From f46230b0edc3f024d07e850adc58e2dfa26f233f Mon Sep 17 00:00:00 2001 From: WFH Brian Date: Mon, 2 Dec 2024 16:49:12 -0500 Subject: [PATCH] Enhance SmartThread and related components to support improved context input including internal embedded links - Added functionality to handle internal embedded links (![[link]]) in SmartThread, allowing for inline processing and context extraction. - Updated message rendering in components to display embedded links correctly. - Refactored chat input handling to improve user experience with context suggestions. - Introduced new utility functions for detecting and extracting internal embedded links. - Updated tests to cover new embedded link functionality and ensure reliability. --- smart-chats/components/message.js | 1 + smart-chats/components/thread.js | 23 +-- smart-chats/smart_thread.js | 178 +++++++++++------------ smart-chats/utils/internal_links.js | 16 ++ smart-chats/utils/internal_links.test.js | 31 +++- 5 files changed, 134 insertions(+), 115 deletions(-) diff --git a/smart-chats/components/message.js b/smart-chats/components/message.js index 790750d0..5579bd86 100644 --- a/smart-chats/components/message.js +++ b/smart-chats/components/message.js @@ -16,6 +16,7 @@ export function build_html(message, opts = {}) { // return `Chat image`; return ' ![[' + part.input.image_path + ']] '; } + if(part.type === 'text' && part.input?.key?.length) return ' ![[' + part.input.key + ']] '; if(part.type === 'text' && part.text?.length) return part.text; }).join('\n') : message.content diff --git a/smart-chats/components/thread.js b/smart-chats/components/thread.js index 6bbc591e..5ea66c5c 100644 --- a/smart-chats/components/thread.js +++ b/smart-chats/components/thread.js @@ -30,7 +30,7 @@ export function build_html(thread, opts = {}) {
- +