feat: follow ups backend integration
This commit is contained in:
@@ -300,6 +300,8 @@
|
||||
message.content = data.content;
|
||||
} else if (type === 'chat:message:files' || type === 'files') {
|
||||
message.files = data.files;
|
||||
} else if (type === 'chat:message:follow_ups') {
|
||||
message.followUps = data.follow_ups;
|
||||
} else if (type === 'chat:title') {
|
||||
chatTitle.set(data);
|
||||
currentChatPage.set(1);
|
||||
@@ -1678,19 +1680,20 @@
|
||||
chat_id: $chatId,
|
||||
id: responseMessageId,
|
||||
|
||||
...(!$temporaryChatEnabled &&
|
||||
(messages.length == 1 ||
|
||||
(messages.length == 2 &&
|
||||
messages.at(0)?.role === 'system' &&
|
||||
messages.at(1)?.role === 'user')) &&
|
||||
(selectedModels[0] === model.id || atSelectedModel !== undefined)
|
||||
? {
|
||||
background_tasks: {
|
||||
background_tasks: {
|
||||
...(!$temporaryChatEnabled &&
|
||||
(messages.length == 1 ||
|
||||
(messages.length == 2 &&
|
||||
messages.at(0)?.role === 'system' &&
|
||||
messages.at(1)?.role === 'user')) &&
|
||||
(selectedModels[0] === model.id || atSelectedModel !== undefined)
|
||||
? {
|
||||
title_generation: $settings?.title?.auto ?? true,
|
||||
tags_generation: $settings?.autoTags ?? true
|
||||
}
|
||||
}
|
||||
: {}),
|
||||
: {}),
|
||||
follow_up_generation: $settings?.autoFollowUps ?? true
|
||||
},
|
||||
|
||||
...(stream && (model.info?.meta?.capabilities?.usage ?? false)
|
||||
? {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
src.startsWith('/')
|
||||
? src
|
||||
: `/user.png`}
|
||||
class=" {className} object-cover rounded-full -translate-y-[1px]"
|
||||
class=" {className} object-cover rounded-full"
|
||||
alt="profile"
|
||||
draggable="false"
|
||||
/>
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
import ContentRenderer from './ContentRenderer.svelte';
|
||||
import { KokoroWorker } from '$lib/workers/KokoroWorker';
|
||||
import FileItem from '$lib/components/common/FileItem.svelte';
|
||||
import FollowUps from './ResponseMessage/FollowUps.svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
interface MessageType {
|
||||
id: string;
|
||||
@@ -606,7 +608,7 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex-auto w-0 pl-1 relative">
|
||||
<div class="flex-auto w-0 pl-1 relative -translate-y-0.5">
|
||||
<Name>
|
||||
<Tooltip content={model?.name ?? message.model} placement="top-start">
|
||||
<span class="line-clamp-1 text-black dark:text-white">
|
||||
@@ -1425,6 +1427,17 @@
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if isLastMessage && message.done && !readOnly && (message?.followUps ?? []).length > 0}
|
||||
<div class="mt-2.5" in:fade={{ duration: 50 }}>
|
||||
<FollowUps
|
||||
followUps={message?.followUps}
|
||||
onClick={() => {
|
||||
console.log('Follow-ups clicked');
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<script lang="ts">
|
||||
import { onMount, tick, getContext } from 'svelte';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
export let followUps: string[] = [];
|
||||
export let onClick: (followUp: string) => void = () => {};
|
||||
</script>
|
||||
|
||||
<div class="mt-2">
|
||||
<div class="text-xs text-gray-500 font-medium">
|
||||
{$i18n.t('Follow up')}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col text-left gap-1 mt-1.5">
|
||||
{#each followUps as followUp, idx (idx)}
|
||||
<button
|
||||
class=" mr-2 py-1 bg-transparent text-left text-xs"
|
||||
on:click={() => onClick(followUp)}
|
||||
title={followUp}
|
||||
aria-label={followUp}
|
||||
>
|
||||
{followUp}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
// Addons
|
||||
let titleAutoGenerate = true;
|
||||
let autoFollowUps = true;
|
||||
let autoTags = true;
|
||||
|
||||
let responseAutoCopy = false;
|
||||
@@ -197,6 +198,11 @@
|
||||
});
|
||||
};
|
||||
|
||||
const toggleAutoFollowUps = async () => {
|
||||
autoFollowUps = !autoFollowUps;
|
||||
saveSettings({ autoFollowUps });
|
||||
};
|
||||
|
||||
const toggleAutoTags = async () => {
|
||||
autoTags = !autoTags;
|
||||
saveSettings({ autoTags });
|
||||
@@ -619,6 +625,26 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class=" py-0.5 flex w-full justify-between">
|
||||
<div class=" self-center text-xs">{$i18n.t('Follow-Up Auto-Generation')}</div>
|
||||
|
||||
<button
|
||||
class="p-1 px-3 text-xs flex rounded-sm transition"
|
||||
on:click={() => {
|
||||
toggleAutoFollowUps();
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
{#if autoFollowUps === true}
|
||||
<span class="ml-2 self-center">{$i18n.t('On')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Off')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class=" py-0.5 flex w-full justify-between">
|
||||
<div class=" self-center text-xs">{$i18n.t('Chat Tags Auto-Generation')}</div>
|
||||
|
||||
Reference in New Issue
Block a user