-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
864 additions
and
68 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<script lang="ts"> | ||
import type { PdfSearchUpdate } from "$lib/types/MessageUpdate"; | ||
import CarbonCaretRight from "~icons/carbon/caret-right"; | ||
import CarbonCheckmark from "~icons/carbon/checkmark-filled"; | ||
import CarbonError from "~icons/carbon/error-filled"; | ||
import EosIconsLoading from "~icons/eos-icons/loading"; | ||
export let loading = false; | ||
export let classNames = ""; | ||
export let pdfSearchMessages: PdfSearchUpdate[] = []; | ||
let detailsOpen: boolean; | ||
let error: boolean; | ||
$: error = pdfSearchMessages[pdfSearchMessages.length - 1]?.messageType === "error"; | ||
</script> | ||
|
||
<details | ||
class="flex w-fit rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-900 {classNames} max-w-full" | ||
bind:open={detailsOpen} | ||
> | ||
<summary | ||
class="align-center flex cursor-pointer select-none list-none py-1 pl-2.5 pr-2 align-text-top transition-all" | ||
> | ||
{#if error} | ||
<CarbonError class="my-auto text-red-700 dark:text-red-500" /> | ||
{:else if loading} | ||
<EosIconsLoading class="my-auto text-gray-500" /> | ||
{:else} | ||
<CarbonCheckmark class="my-auto text-gray-500" /> | ||
{/if} | ||
<span class="px-2 font-medium" class:text-red-700={error} class:dark:text-red-500={error} | ||
>PDF search | ||
</span> | ||
<div class="my-auto transition-all" class:rotate-90={detailsOpen}> | ||
<CarbonCaretRight /> | ||
</div> | ||
</summary> | ||
|
||
<div class="content px-5 pb-5 pt-4"> | ||
{#if pdfSearchMessages.length === 0} | ||
<div class="mx-auto w-fit"> | ||
<EosIconsLoading class="mb-3 h-4 w-4" /> | ||
</div> | ||
{:else} | ||
<ol> | ||
{#each pdfSearchMessages as message} | ||
{#if message.messageType === "update"} | ||
<li class="group border-l pb-6 last:!border-transparent last:pb-0 dark:border-gray-800"> | ||
<div class="flex items-start"> | ||
<div | ||
class="-ml-1.5 h-3 w-3 flex-none rounded-full bg-gray-200 dark:bg-gray-600 {loading | ||
? 'group-last:animate-pulse group-last:bg-gray-300 group-last:dark:bg-gray-500' | ||
: ''}" | ||
/> | ||
<h3 class="text-md -mt-1.5 pl-2.5 text-gray-800 dark:text-gray-100"> | ||
{message.message} | ||
</h3> | ||
</div> | ||
{#if message.args} | ||
<p class="mt-1.5 pl-4 text-gray-500 dark:text-gray-400"> | ||
{message.args} | ||
</p> | ||
{/if} | ||
</li> | ||
{:else if message.messageType === "error"} | ||
<li class="group border-l pb-6 last:!border-transparent last:pb-0 dark:border-gray-800"> | ||
<div class="flex items-start"> | ||
<CarbonError | ||
class="-ml-1.5 h-3 w-3 flex-none scale-110 text-red-700 dark:text-red-500" | ||
/> | ||
<h3 class="text-md -mt-1.5 pl-2.5 text-red-700 dark:text-red-500"> | ||
{message.message} | ||
</h3> | ||
</div> | ||
{#if message.args} | ||
<p class="mt-1.5 pl-4 text-gray-500 dark:text-gray-400"> | ||
{message.args} | ||
</p> | ||
{/if} | ||
</li> | ||
{/if} | ||
{/each} | ||
</ol> | ||
{/if} | ||
</div> | ||
</details> | ||
|
||
<style> | ||
@keyframes grow { | ||
0% { | ||
font-size: 0; | ||
opacity: 0; | ||
} | ||
30% { | ||
font-size: 1em; | ||
opacity: 0; | ||
} | ||
100% { | ||
opacity: 1; | ||
} | ||
} | ||
details[open] .content { | ||
animation-name: grow; | ||
animation-duration: 300ms; | ||
animation-delay: 0ms; | ||
} | ||
details summary::-webkit-details-marker { | ||
display: none; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,52 @@ | ||
<script lang="ts"> | ||
import {createEventDispatcher} from "svelte"; | ||
import CarbonUpload from "~icons/carbon/upload"; | ||
export let classNames = ""; | ||
export let multimodal = false; | ||
export let files: File[]; | ||
let filelist: FileList; | ||
export let uploadingPdf = false; | ||
const accept = multimodal ? "image/*,.pdf" : ".pdf"; | ||
const label = multimodal ? "Upload image or PDF" : "Upload PDF"; | ||
let fileInput: HTMLInputElement; | ||
$: if (filelist) { | ||
files = Array.from(filelist); | ||
const dispatch = createEventDispatcher<{ | ||
uploadpdf: File; | ||
}>(); | ||
function onChange() { | ||
if(!fileInput.files){ | ||
return; | ||
} | ||
const file = fileInput.files?.[0]; | ||
if (file?.type === "application/pdf") { | ||
// pdf upload | ||
dispatch("uploadpdf", file); | ||
}else{ | ||
// image files for multimodal models | ||
files = Array.from(fileInput.files); | ||
} | ||
} | ||
</script> | ||
|
||
<button | ||
class="btn relative h-8 rounded-lg border bg-white px-3 py-1 text-sm text-gray-500 shadow-sm transition-all hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600 {classNames}" | ||
class:animate-pulse={uploadingPdf} | ||
class:pointer-events-none={uploadingPdf} | ||
> | ||
<input | ||
bind:files={filelist} | ||
bind:this={fileInput} | ||
on:change={onChange} | ||
class="absolute w-full cursor-pointer opacity-0" | ||
type="file" | ||
accept="image/*" | ||
{accept} | ||
/> | ||
<CarbonUpload class="mr-2 text-xs " /> Upload image | ||
<CarbonUpload class="mr-2 text-xs " /> | ||
{#if uploadingPdf} | ||
Processing PDF file | ||
{:else} | ||
{label} | ||
{/if} | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.