forked from open-webui/open-webui
feat: modelfile content linked to chat page
This commit is contained in:
parent
12d7ae96b9
commit
587101da88
5 changed files with 148 additions and 128 deletions
|
@ -7,17 +7,24 @@
|
|||
import { splitStream } from '$lib/utils';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import { config, user, settings, db, chats, chatId } from '$lib/stores';
|
||||
import { config, modelfiles, user, settings, db, chats, chatId } from '$lib/stores';
|
||||
|
||||
import MessageInput from '$lib/components/chat/MessageInput.svelte';
|
||||
import Messages from '$lib/components/chat/Messages.svelte';
|
||||
import ModelSelector from '$lib/components/chat/ModelSelector.svelte';
|
||||
import Navbar from '$lib/components/layout/Navbar.svelte';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
let stopResponseFlag = false;
|
||||
let autoScroll = true;
|
||||
|
||||
let selectedModels = [''];
|
||||
let selectedModelfile = null;
|
||||
$: selectedModelfile =
|
||||
selectedModels.length === 1 &&
|
||||
$modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0]).length > 0
|
||||
? $modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0])[0]
|
||||
: null;
|
||||
|
||||
let title = '';
|
||||
let prompt = '';
|
||||
|
@ -64,7 +71,9 @@
|
|||
messages: {},
|
||||
currentId: null
|
||||
};
|
||||
selectedModels = $settings.models ?? [''];
|
||||
selectedModels = $page.url.searchParams.get('models')
|
||||
? $page.url.searchParams.get('models')?.split(',')
|
||||
: $settings.models ?? [''];
|
||||
};
|
||||
|
||||
//////////////////////////
|
||||
|
@ -487,9 +496,42 @@
|
|||
</div>
|
||||
|
||||
<div class=" h-full mt-10 mb-32 w-full flex flex-col">
|
||||
<Messages bind:history bind:messages bind:autoScroll {sendPrompt} {regenerateResponse} />
|
||||
<Messages
|
||||
{selectedModels}
|
||||
{selectedModelfile}
|
||||
bind:history
|
||||
bind:messages
|
||||
bind:autoScroll
|
||||
{sendPrompt}
|
||||
{regenerateResponse}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<MessageInput bind:prompt bind:files bind:autoScroll {messages} {submitPrompt} {stopResponse} />
|
||||
<MessageInput
|
||||
bind:prompt
|
||||
bind:files
|
||||
bind:autoScroll
|
||||
suggestionPrompts={selectedModelfile?.suggestionPrompts ?? [
|
||||
{
|
||||
title: ['Help me study', 'vocabulary for a college entrance exam'],
|
||||
content: `Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option.`
|
||||
},
|
||||
{
|
||||
title: ['Give me ideas', `for what to do with my kids' art`],
|
||||
content: `What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter.`
|
||||
},
|
||||
{
|
||||
title: ['Tell me a fun fact', 'about the Roman Empire'],
|
||||
content: 'Tell me a random fun fact about the Roman Empire'
|
||||
},
|
||||
{
|
||||
title: ['Show me a code snippet', `of a website's sticky header`],
|
||||
content: `Show me a code snippet of a website's sticky header in CSS and JavaScript.`
|
||||
}
|
||||
]}
|
||||
{messages}
|
||||
{submitPrompt}
|
||||
{stopResponse}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { onMount, tick } from 'svelte';
|
||||
import { convertMessagesToHistory, splitStream } from '$lib/utils';
|
||||
import { goto } from '$app/navigation';
|
||||
import { config, user, settings, db, chats, chatId } from '$lib/stores';
|
||||
import { config, modelfiles, user, settings, db, chats, chatId } from '$lib/stores';
|
||||
|
||||
import MessageInput from '$lib/components/chat/MessageInput.svelte';
|
||||
import Messages from '$lib/components/chat/Messages.svelte';
|
||||
|
@ -20,6 +20,12 @@
|
|||
|
||||
// let chatId = $page.params.id;
|
||||
let selectedModels = [''];
|
||||
let selectedModelfile = null;
|
||||
$: selectedModelfile =
|
||||
selectedModels.length === 1 &&
|
||||
$modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0]).length > 0
|
||||
? $modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0])[0]
|
||||
: null;
|
||||
|
||||
let title = '';
|
||||
let prompt = '';
|
||||
|
@ -521,10 +527,42 @@
|
|||
</div>
|
||||
|
||||
<div class=" h-full mt-10 mb-32 w-full flex flex-col">
|
||||
<Messages bind:history bind:messages bind:autoScroll {sendPrompt} {regenerateResponse} />
|
||||
<Messages
|
||||
{selectedModels}
|
||||
{selectedModelfile}
|
||||
bind:history
|
||||
bind:messages
|
||||
bind:autoScroll
|
||||
{sendPrompt}
|
||||
{regenerateResponse}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<MessageInput bind:prompt bind:autoScroll {messages} {submitPrompt} {stopResponse} />
|
||||
<MessageInput
|
||||
bind:prompt
|
||||
bind:autoScroll
|
||||
suggestionPrompts={selectedModelfile?.suggestionPrompts ?? [
|
||||
{
|
||||
title: ['Help me study', 'vocabulary for a college entrance exam'],
|
||||
content: `Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option.`
|
||||
},
|
||||
{
|
||||
title: ['Give me ideas', `for what to do with my kids' art`],
|
||||
content: `What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter.`
|
||||
},
|
||||
{
|
||||
title: ['Tell me a fun fact', 'about the Roman Empire'],
|
||||
content: 'Tell me a random fun fact about the Roman Empire'
|
||||
},
|
||||
{
|
||||
title: ['Show me a code snippet', `of a website's sticky header`],
|
||||
content: `Show me a code snippet of a website's sticky header in CSS and JavaScript.`
|
||||
}
|
||||
]}
|
||||
{messages}
|
||||
{submitPrompt}
|
||||
{stopResponse}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue