From f00a87fc0641b5df5c7923fe2978abc68148b8e3 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Tue, 16 Jul 2024 03:47:23 -0700 Subject: [PATCH] Attachments: pure-image website attachments --- .../composer/llmattachments/LLMAttachmentButton.tsx | 3 ++- src/common/attachment-drafts/attachment.pipeline.ts | 10 +++++++++- src/common/attachment-drafts/attachment.types.ts | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/apps/chat/components/composer/llmattachments/LLMAttachmentButton.tsx b/src/apps/chat/components/composer/llmattachments/LLMAttachmentButton.tsx index 90b030c1f..14fa3e9c3 100644 --- a/src/apps/chat/components/composer/llmattachments/LLMAttachmentButton.tsx +++ b/src/apps/chat/components/composer/llmattachments/LLMAttachmentButton.tsx @@ -73,7 +73,7 @@ const InputErrorIndicator = () => ; -const converterTypeToIconMap: { [key in AttachmentDraftConverterType]: React.ComponentType } = { +const converterTypeToIconMap: { [key in AttachmentDraftConverterType]: React.ComponentType | null } = { 'text': TextFieldsIcon, 'rich-text': CodeIcon, 'rich-text-cleaner': CodeIcon, @@ -89,6 +89,7 @@ const converterTypeToIconMap: { [key in AttachmentDraftConverterType]: React.Com 'url-page-text': TextFieldsIcon, // was LanguageIcon 'url-page-markdown': CodeIcon, // was LanguageIcon 'url-page-html': HtmlIcon, // was LanguageIcon + 'url-page-null': TextureIcon, 'url-page-image': ImageOutlinedIcon, 'ego-fragments-inlined': TelegramIcon, 'unhandled': TextureIcon, diff --git a/src/common/attachment-drafts/attachment.pipeline.ts b/src/common/attachment-drafts/attachment.pipeline.ts index a19a44bc5..ec346683f 100644 --- a/src/common/attachment-drafts/attachment.pipeline.ts +++ b/src/common/attachment-drafts/attachment.pipeline.ts @@ -319,8 +319,11 @@ export function attachmentDefineConverters(sourceType: AttachmentDraftSource['me converters.push({ id: 'url-page-markdown', name: 'Markdown (suggested)', isActive: preferMarkdown }); if (pageData.pageCleanedHtml) converters.push({ id: 'url-page-html', name: 'Clean HTML', isActive: !preferMarkdown && !pageData.pageText }); - if (input.urlImage) + if (input.urlImage) { + if (converters.length) + converters.push({ id: 'url-page-null', name: 'Do not attach' }); converters.push({ id: 'url-page-image', name: 'Add Screenshot', disabled: !input.urlImage.width || !input.urlImage.height, isCheckbox: true }); + } break; // EGO @@ -656,6 +659,11 @@ export async function attachmentPerformConversion( newFragments.push(createDocAttachmentFragment(title, caption, 'text/html', pageHtmlData, refString, docMeta)); break; + // url page null + case 'url-page-null': + // user chose to not attach any version of the page + break; + // url page image case 'url-page-image': if (!input.urlImage) { diff --git a/src/common/attachment-drafts/attachment.types.ts b/src/common/attachment-drafts/attachment.types.ts index f9be2367e..dbafa8319 100644 --- a/src/common/attachment-drafts/attachment.types.ts +++ b/src/common/attachment-drafts/attachment.types.ts @@ -123,7 +123,7 @@ export type AttachmentDraftConverterType = | 'image-original' | 'image-resized-high' | 'image-resized-low' | 'image-ocr' | 'image-to-default' | 'pdf-text' | 'pdf-images' | 'docx-to-html' - | 'url-page-text' | 'url-page-markdown' | 'url-page-html' | 'url-page-image' + | 'url-page-text' | 'url-page-markdown' | 'url-page-html' | 'url-page-null' | 'url-page-image' | 'ego-fragments-inlined' | 'unhandled';