Skip to content

Commit

Permalink
feat: put file upload icon first so its always visible and make tools…
Browse files Browse the repository at this point in the history
… scrollable on mobile
  • Loading branch information
nsarrazin committed Dec 25, 2024
1 parent 3cd714f commit d7c72e0
Showing 1 changed file with 39 additions and 38 deletions.
77 changes: 39 additions & 38 deletions src/lib/components/chat/ChatInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,46 @@
</div>
{#if !assistant}
<div
class="-ml-0.5 flex flex-wrap items-center justify-start gap-2.5 px-3 pb-2.5 text-gray-500 dark:text-gray-400"
class="scrollbar-custom -ml-0.5 flex max-w-[90dvw] flex-wrap items-center justify-start gap-2.5 px-3 pb-2.5
text-gray-500 dark:text-gray-400 max-md:flex-nowrap max-md:overflow-x-auto"
>
{#if modelIsMultimodal || modelHasTools}
{@const mimeTypesString = mimeTypes
.map((m) => {
// if the mime type ends in *, grab the first part so image/* becomes image
if (m.endsWith("*")) {
return m.split("/")[0];
}
// otherwise, return the second part for example application/pdf becomes pdf
return m.split("/")[1];
})
.join(", ")}
<form class="flex items-center">
<HoverTooltip
label={`Upload ${mimeTypesString} files`}
position="top"
TooltipClassNames="text-xs !text-left !w-auto whitespace-nowrap !py-1 !mb-0 max-sm:hidden"
>
<button
class="base-tool relative"
class:active-tool={documentParserIsOn}
disabled={loading}
>
<input
class="absolute w-full cursor-pointer opacity-0"
aria-label="Upload file"
type="file"
on:change={onFileChange}
accept={mimeTypes.join(",")}
/>
<IconPaperclip classNames="text-xl" />
{#if documentParserIsOn}
Document Parser
{/if}
</button>
</HoverTooltip>
</form>
{/if}
<HoverTooltip
label="Search the web"
position="top"
Expand Down Expand Up @@ -226,43 +264,6 @@
</button>
{/each}
{/if}
{#if modelIsMultimodal || modelHasTools}
{@const mimeTypesString = mimeTypes
.map((m) => {
// if the mime type ends in *, grab the first part so image/* becomes image
if (m.endsWith("*")) {
return m.split("/")[0];
}
// otherwise, return the second part for example application/pdf becomes pdf
return m.split("/")[1];
})
.join(", ")}
<form class="flex items-center">
<HoverTooltip
label={`Upload ${mimeTypesString} files`}
position="top"
TooltipClassNames="text-xs !text-left !w-auto whitespace-nowrap !py-1 !mb-0 max-sm:hidden"
>
<button
class="base-tool relative"
class:active-tool={documentParserIsOn}
disabled={loading}
>
<input
class="absolute w-full cursor-pointer opacity-0"
aria-label="Upload file"
type="file"
on:change={onFileChange}
accept={mimeTypes.join(",")}
/>
<IconPaperclip classNames="text-xl" />
{#if documentParserIsOn}
Document Parser
{/if}
</button>
</HoverTooltip>
</form>
{/if}
{#if modelHasTools}
<HoverTooltip
label="Browse more tools"
Expand Down

1 comment on commit d7c72e0

@gary149
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this change I like having web search first I think it's way more used than file.

Please sign in to comment.