Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update tooltip to same as ui package #1077

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/frontend/src/lib/ErrorMessage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ export let icon = false;

{#if icon}
{#if error !== undefined && error !== ''}
<Tooltip tip="{error}" top>
<Fa size="1.125x" class="cursor-pointer text-red-500 {$$props.class}" icon="{faExclamationCircle}" />
<Tooltip top>
<svelte:fragment slot="content">
<Fa size="1.125x" class="cursor-pointer text-red-500 {$$props.class}" icon="{faExclamationCircle}" />
</svelte:fragment>
<svelte:fragment slot="tip">
{#if error}
<div class="inline-block py-2 px-4 rounded-md bg-charcoal-800 text-xs" aria-label="tooltip">{error}</div>
{/if}
</svelte:fragment>
</Tooltip>
{/if}
{:else}
Expand Down
27 changes: 20 additions & 7 deletions packages/frontend/src/lib/Tooltip.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
transform: translate(-80%, -100%);
margin-top: -8px;
}
.tooltip.bottom-left {
left: 0;
bottom: 0;
transform: translate(-80%, 100%);
margin-top: -8px;
}
.tooltip.bottom-right {
left: 0;
bottom: 0;
transform: translate(0%, 100%);
margin-top: -8px;
}
.tooltip.top-right {
left: 0;
transform: translate(0%, -100%);
Expand All @@ -38,18 +50,19 @@
</style>

<script>
export let tip = '';
export let top = false;
export let topLeft = false;
export let topRight = false;
export let right = false;
export let bottom = false;
export let bottomLeft = false;
export let bottomRight = false;
export let left = false;
</script>

<div class="relative inline-block">
<span class="group tooltip-slot">
<slot />
<span class="group tooltip-slot {$$props.class}">
<slot name="content" />
</span>
<div
class="whitespace-nowrap absolute tooltip opacity-0 inline-block transition-opacity duration-150 ease-in-out pointer-events-none z-[10]"
Expand All @@ -58,9 +71,9 @@ export let left = false;
class:bottom="{bottom}"
class:top="{top}"
class:top-left="{topLeft}"
class:top-right="{topRight}">
{#if tip}
<div class="inline-block py-2 px-4 rounded-md bg-charcoal-800 text-xs" aria-label="tooltip">{tip}</div>
{/if}
class:top-right="{topRight}"
class:bottom-left="{bottomLeft}"
class:bottom-right="{bottomRight}">
<slot name="tip" />
</div>
</div>
42 changes: 33 additions & 9 deletions packages/frontend/src/pages/Playground.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,49 @@ function getSendPromptTitle(sendEnabled: boolean, status?: string, health?: stri
<div class="w-full">
<RangeInput name="temperature" min="0" max="2" step="0.1" bind:value="{temperature}" />
</div>
<Tooltip
tip="What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic."
left="{true}"><Fa icon="{faCircleInfo}" /></Tooltip>
<Tooltip left>
<svelte:fragment slot="content">
<Fa icon="{faCircleInfo}" />
</svelte:fragment>
<svelte:fragment slot="tip">
<div class="inline-block py-2 px-4 rounded-md bg-charcoal-800 text-xs" aria-label="tooltip">
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output
more random, while lower values like 0.2 will make it more focused and deterministic.
</div>
</svelte:fragment>
</Tooltip>
</div>
<div class="flex flex-row">
<div class="w-full">
<RangeInput name="max tokens" min="-1" max="32768" step="1" bind:value="{max_tokens}" />
</div>
<Tooltip
tip="The maximum number of tokens that can be generated in the chat completion."
left="{true}"><Fa icon="{faCircleInfo}" /></Tooltip>
<Tooltip left>
<svelte:fragment slot="content">
<Fa icon="{faCircleInfo}" />
</svelte:fragment>
<svelte:fragment slot="tip">
<div class="inline-block py-2 px-4 rounded-md bg-charcoal-800 text-xs" aria-label="tooltip">
The maximum number of tokens that can be generated in the chat completion.
</div>
</svelte:fragment>
</Tooltip>
</div>
<div class="flex flex-row">
<div class="w-full">
<RangeInput name="top-p" min="0" max="1" step="0.1" bind:value="{top_p}" />
</div>
<Tooltip
tip="An alternative to sampling with temperature, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered."
left="{true}"><Fa icon="{faCircleInfo}" /></Tooltip>
<Tooltip left>
<svelte:fragment slot="content">
<Fa icon="{faCircleInfo}" />
</svelte:fragment>
<svelte:fragment slot="tip">
<div class="inline-block py-2 px-4 rounded-md bg-charcoal-800 text-xs" aria-label="tooltip">
An alternative to sampling with temperature, where the model considers the results of the
tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10%
probability mass are considered.
</div>
</svelte:fragment>
</Tooltip>
</div>
</div>
</div>
Expand Down