|
25 | 25 | import { onMount, setContext, tick } from 'svelte'; |
26 | 26 | import Viewport from 'svelte-viewport-info'; |
27 | 27 | import { PUBLIC_LIVECHAT_ENTRY_ICON } from '$env/static/public'; |
28 | | - import { BOT_SENDERS, TEXT_EDITORS, USER_SENDERS } from '$lib/helpers/constants'; |
| 28 | + import { BOT_SENDERS, LERNER_ID, TEXT_EDITORS, TRAINING_MODE, USER_SENDERS } from '$lib/helpers/constants'; |
29 | 29 | import { signalr } from '$lib/services/signalr-service.js'; |
30 | 30 | import { webSpeech } from '$lib/services/web-speech.js'; |
31 | 31 | import { newConversation } from '$lib/services/conversation-service'; |
|
130 | 130 | let autoScrollLog = false; |
131 | 131 | let disableAction = false; |
132 | 132 |
|
| 133 | + /** @type {string} */ |
| 134 | + let mode = ''; |
| 135 | +
|
133 | 136 | $: { |
134 | 137 | const editor = lastBotMsg?.rich_content?.editor || ''; |
135 | 138 | loadTextEditor = TEXT_EDITORS.includes(editor) || !Object.values(EditorType).includes(editor); |
|
184 | 187 |
|
185 | 188 | function initChatView() { |
186 | 189 | isFrame = $page.url.searchParams.get('isFrame') === 'true'; |
| 190 | + mode = $page.url.searchParams.get('mode') || ''; |
187 | 191 | // initial condition |
188 | 192 | isPersistLogClosed = false; |
189 | 193 | isInstantLogClosed = false; |
|
394 | 398 | window.location.href = url; |
395 | 399 | } |
396 | 400 |
|
| 401 | + function handleSaveKnowledge() { |
| 402 | + sendChatMessage("Save knowledge"); |
| 403 | + } |
397 | 404 |
|
398 | 405 | /** |
399 | 406 | * @param {string} msgText |
|
952 | 959 | </Dropdown> |
953 | 960 | </li> |
954 | 961 | {/if} |
955 | | - <DropdownItem on:click={handleNewConversation}>New Conversation</DropdownItem> |
| 962 | + <DropdownItem on:click={() => handleNewConversation()}>New Conversation</DropdownItem> |
| 963 | + {#if agent?.id === LERNER_ID && mode === TRAINING_MODE} |
| 964 | + <DropdownItem on:click={() => handleSaveKnowledge()}>Save Knowledge</DropdownItem> |
| 965 | + {/if} |
956 | 966 | </DropdownMenu> |
957 | 967 | </Dropdown> |
958 | 968 | </li> |
959 | 969 | |
960 | 970 | <li class="list-inline-item d-md-inline-block"> |
961 | 971 | <button |
962 | | - class="btn btn-primary btn-rounded btn-sm chat-send waves-effect waves-light" |
| 972 | + class={`btn btn-rounded btn-sm chat-send waves-effect waves-light ${mode === TRAINING_MODE ? 'btn-danger' : 'btn-primary'}`} |
963 | 973 | disabled={disableAction} |
964 | 974 | on:click={() => endChat()} |
965 | 975 | > |
|
1087 | 1097 | <div class="col-auto"> |
1088 | 1098 | <button |
1089 | 1099 | type="submit" |
1090 | | - class="btn btn-primary btn-rounded waves-effect waves-light" |
| 1100 | + class={`btn btn-rounded waves-effect waves-light ${mode === TRAINING_MODE ? 'btn-danger' : 'btn-primary'}`} |
1091 | 1101 | disabled={isSendingMsg || isThinking || disableAction} |
1092 | 1102 | on:click={startListen} |
1093 | 1103 | > |
|
1114 | 1124 | <div class="col-auto"> |
1115 | 1125 | <button |
1116 | 1126 | type="submit" |
1117 | | - class="btn btn-primary btn-rounded chat-send waves-effect waves-light" |
| 1127 | + class={`btn btn-rounded chat-send waves-effect waves-light ${mode === TRAINING_MODE ? 'btn-danger' : 'btn-primary'}`} |
1118 | 1128 | disabled={!!!_.trim(text) || isSendingMsg || isThinking || disableAction} |
1119 | 1129 | on:click={() => sentTextMessage()} |
1120 | 1130 | ><span class="d-none d-md-inline-block me-2">Send</span> |
|
0 commit comments