diff --git a/src/lib/scss/custom/pages/_instruction.scss b/src/lib/scss/custom/pages/_instruction.scss index 3a06401c..067f6d1f 100644 --- a/src/lib/scss/custom/pages/_instruction.scss +++ b/src/lib/scss/custom/pages/_instruction.scss @@ -48,7 +48,7 @@ } .instruction-gap { - margin-top: 10px; + margin-top: 30px; } } @@ -79,7 +79,7 @@ .instruct-state-item { display: flex; - gap: 10px; + gap: 30px; justify-content: center; } } \ No newline at end of file diff --git a/src/routes/page/instruction/+page.svelte b/src/routes/page/instruction/+page.svelte index 33c42a57..7705c9ff 100644 --- a/src/routes/page/instruction/+page.svelte +++ b/src/routes/page/instruction/+page.svelte @@ -3,23 +3,33 @@ import { fly } from 'svelte/transition'; import { _ } from 'svelte-i18n'; import util from "lodash"; - import { Button, Col, Row } from '@sveltestrap/sveltestrap'; + import { Button, Card, CardBody, Col, Row } from '@sveltestrap/sveltestrap'; import LoadingDots from '$lib/common/LoadingDots.svelte'; import HeadTitle from '$lib/common/HeadTitle.svelte'; import Breadcrumb from '$lib/common/Breadcrumb.svelte'; import Markdown from '$lib/common/markdown/Markdown.svelte'; - import InstructionSetting from './instruction-components/instruction-setting.svelte'; import InstructionState from './instruction-components/instruction-state.svelte'; import { getAgents } from '$lib/services/agent-service'; import LoadingToComplete from '$lib/common/LoadingToComplete.svelte'; import { sendChatCompletion } from '$lib/services/instruct-service'; import { getLlmConfigs } from '$lib/services/llm-provider-service'; import { LlmModelType } from '$lib/helpers/enums'; + import NavBar from '$lib/common/nav-bar/NavBar.svelte'; + import NavItem from '$lib/common/nav-bar/NavItem.svelte'; + import InstructionTemplate from './instruction-components/instruction-template.svelte'; + import InstructionLlm from './instruction-components/instruction-llm.svelte'; const maxLength = 64000; const DEFAULT_PROVIDER = 'openai'; const DEFAULT_MODEL = 'gpt-4o-mini'; + /** @type {any[]}*/ + const tabs = [ + { name: 'instruction-template', displayText: 'Template' }, + { name: 'instruction-llm', displayText: 'LLM Config' }, + { name: 'instruction-states', displayText: 'States' } + ]; + let isLoading = false; let isThinking = false; let requestDone = false; @@ -32,7 +42,7 @@ /** @type {import('$agentTypes').AgentModel | null} */ let selectedAgent = null; - /** @type {string | null} */ + /** @type {import('$commonTypes').LlmConfig?} */ let selectedProvider = null; /** @type {string | null} */ @@ -49,6 +59,9 @@ { key: '', value: ''} ]; + /** @type {string}*/ + let selectedTab = tabs[0].name; + onMount(async () => { try { isLoading = true; @@ -62,7 +75,6 @@ } }); - function sendRequest() { isThinking = true; requestDone = false; @@ -73,7 +85,7 @@ text: util.trim(text) || '', instruction: util.trim(instruction) || null, agentId: selectedAgent?.id, - provider: selectedProvider || DEFAULT_PROVIDER, + provider: selectedProvider?.provider || DEFAULT_PROVIDER, model: selectedModel || DEFAULT_MODEL, states: formattedStates }).then(res => { @@ -121,21 +133,29 @@ /** @param {any} e */ function onAgentSelected(e) { - selectedAgent = e.detail.selectedAgent || null; + selectedAgent = e.detail.agent || null; instruction = selectedAgent?.instruction || ''; - const template = e.detail.selectedTemplate || null; + const template = e.detail.template || null; if (!!template) { instruction = template?.content || ''; } - onLlmSelected(e); + const providerName = selectedAgent?.llm_config?.provider || null; + const modelName = selectedAgent?.llm_config?.model || null; + selectedProvider = llmConfigs?.find(x => x.provider === providerName) || null; + selectedModel = modelName; } /** @param {any} e */ function onLlmSelected(e) { - selectedProvider = e.detail.selectedProvider || null; - selectedModel = e.detail.selectedModel || ''; + selectedProvider = e.detail.provider || null; + selectedModel = e.detail.model || ''; + } + + /** @param {string} selected */ + function handleTabClick(selected) { + selectedTab = selected; } @@ -151,7 +171,7 @@ rows={8} maxlength={maxLength} disabled={isThinking} - placeholder={'Start typing here...'} + placeholder={'Enter input message...'} bind:value={text} on:keydown={(e) => pressKey(e)} /> @@ -207,55 +227,95 @@ - -
-
- onAgentSelected(e)} - on:llmSelected={e => onLlmSelected(e)} - /> -
-
- -
+ + +
+
+ {'Instruction'} +
+
+ + + resetInstruction()} + /> +
+
+ + +
- +
-
-
- {'Instruction'} -
-
- - - resetInstruction()} - /> -
-
-
+