From 2cef5a29f2a3ba4b7cc387243e77f39f833da2c0 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Wed, 4 Sep 2024 16:24:09 -0500 Subject: [PATCH 1/5] refine user state modal --- src/lib/common/StateModal.svelte | 14 ++++---- src/lib/helpers/store.js | 34 +++++++++++++------ src/lib/scss/custom/pages/_chat.scss | 8 ++--- src/lib/services/conversation-service.js | 20 ++++++----- .../[conversationId]/chat-box.svelte | 6 ++-- 5 files changed, 47 insertions(+), 35 deletions(-) diff --git a/src/lib/common/StateModal.svelte b/src/lib/common/StateModal.svelte index 8c37013d..efa01644 100644 --- a/src/lib/common/StateModal.svelte +++ b/src/lib/common/StateModal.svelte @@ -196,15 +196,13 @@ {/if} -
+
{#if idx !== 0} - +
+ + + remove(idx)} /> +
{/if}
diff --git a/src/lib/helpers/store.js b/src/lib/helpers/store.js index 00963214..a6b2b37b 100644 --- a/src/lib/helpers/store.js +++ b/src/lib/helpers/store.js @@ -6,7 +6,7 @@ const conversationKey = "conversation"; const conversationUserStatesKey = "conversation_user_states"; const conversationSearchOptionKey = "conversation_search_option"; const conversationUserMessageKey = "conversation_user_messages"; -const conversationUserAttachmentKey = "conversation_user_attachments"; +const conversationHistoryStatesKey = "conversation_history_states"; /** @type {Writable} */ export const userStore = writable({ id: "", full_name: "", expires: 0, token: null }); @@ -59,10 +59,6 @@ export function getConversationStore() { conversationStore.subscribe(value => { if (browser && value.id) { localStorage.setItem(conversationKey, JSON.stringify(value)); - const state = conversationUserStateStore.get(); - if (state && state.conversationId != value.id) { - conversationUserStateStore.reset(); - } } }); @@ -81,21 +77,39 @@ export const loaderStore = createLoaderStore(); const createConversationUserStateStore = () => { return { - reset: () => { + resetAll: () => { localStorage.removeItem(conversationUserStatesKey); }, - get: () => { + resetOne: (conversationId) => { const json = localStorage.getItem(conversationUserStatesKey); - return json ? JSON.parse(json) : {}; + const content = json ? JSON.parse(json) : {}; + const data = content?.data || []; + const found = data.find(x => x.conversationId === conversationId); + if (!found) return; + + const updated = data.filter(x => x.conversationId !== conversationId); + localStorage.setItem(conversationUserStatesKey, JSON.stringify({ data: updated })); + }, + get: (conversationId) => { + const json = localStorage.getItem(conversationUserStatesKey); + const content = json ? JSON.parse(json) : {}; + const found = content?.data?.find(x => x.conversationId === conversationId); + return found || {}; }, put: (value) => { - localStorage.setItem(conversationUserStatesKey, JSON.stringify(value)); + const conversationId = value?.conversationId; + const json = localStorage.getItem(conversationUserStatesKey); + const content = json ? JSON.parse(json) : {}; + const cur = content?.data?.filter(x => x.conversationId !== conversationId) || []; + const updated = [ ...cur, { ...value } ]; + localStorage.setItem(conversationUserStatesKey, JSON.stringify({ data: updated })); } } }; export const conversationUserStateStore = createConversationUserStateStore(); + const createConversationSearchOptionStore = () => { return { reset: () => { @@ -151,7 +165,7 @@ export const conversationUserAttachmentStore = createConversationUserAttachmentS export function resetLocalStorage(resetUser = false) { - conversationUserStateStore.reset(); + conversationUserStateStore.resetAll(); conversationSearchOptionStore.reset(); conversationUserMessageStore.reset(); conversationUserAttachmentStore.reset(); diff --git a/src/lib/scss/custom/pages/_chat.scss b/src/lib/scss/custom/pages/_chat.scss index cffab636..506e7933 100644 --- a/src/lib/scss/custom/pages/_chat.scss +++ b/src/lib/scss/custom/pages/_chat.scss @@ -620,14 +620,12 @@ .state-delete { flex: 0.1; - - button { - margin-top: 5px; - } + color: var(--bs-danger); + font-size: 17px; } .invalid { - border-color: red; + border-color: var(--bs-danger); } } diff --git a/src/lib/services/conversation-service.js b/src/lib/services/conversation-service.js index 34028010..7f4a128d 100644 --- a/src/lib/services/conversation-service.js +++ b/src/lib/services/conversation-service.js @@ -1,6 +1,6 @@ -import { endpoints } from './api-endpoints.js'; import { replaceUrl } from '$lib/helpers/http'; import axios from 'axios'; +import { endpoints } from './api-endpoints.js'; import { conversationUserStateStore } from '$lib/helpers/store.js'; /** @@ -66,6 +66,7 @@ export async function getConversationFiles(conversationId, messageId, source) { */ export async function deleteConversation(conversationId) { let url = replaceUrl(endpoints.conversationDeletionUrl, {conversationId: conversationId}); + conversationUserStateStore.resetOne(conversationId); const response = await axios.delete(url); return response.data; } @@ -85,10 +86,11 @@ export async function GetDialogs(conversationId) { * send a message to the hub * @param {string} agentId - The agent id * @param {string} conversationId - The conversation id - * @param {string} message - The text message sent to CSR + * @param {string} text - The text message sent to CSR * @param {import('$types').MessageData?} data - Additional data */ -export async function sendMessageToHub(agentId, conversationId, message, data = null) { +export async function sendMessageToHub(agentId, conversationId, text, data = null) { + console.log(data); let url = replaceUrl(endpoints.conversationMessageUrl, { agentId: agentId, conversationId: conversationId @@ -96,7 +98,7 @@ export async function sendMessageToHub(agentId, conversationId, message, data = const userStates = buildConversationUserStates(conversationId); const totalStates = !!data?.states && data?.states?.length > 0 ? [...data.states, ...userStates] : [...userStates]; const response = await axios.post(url, { - text: message, + text: text, states: totalStates, postback: data?.postback, input_message_id: data?.inputMessageId @@ -109,17 +111,17 @@ export async function sendMessageToHub(agentId, conversationId, message, data = * @param {string} conversationId */ function buildConversationUserStates(conversationId) { - const userStates = conversationUserStateStore.get(); - if (!!userStates && userStates.conversationId == conversationId && userStates.states?.length > 0) { + const userStates = conversationUserStateStore.get(conversationId); + if (!!userStates && userStates.conversationId == conversationId) { // @ts-ignore - const states = userStates.states.map(state => { + const states = userStates.states?.map(state => { return { key: state.key.data, value: state.value.data, active_rounds: state.active_rounds.data || -1 }; - }); - conversationUserStateStore.reset(); + }) || []; + conversationUserStateStore.resetOne(conversationId); return states; } return []; diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index 16671b83..f2b8b679 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -727,7 +727,7 @@ } function loadUserAddStates() { - const conversationUserStates = conversationUserStateStore.get(); + const conversationUserStates = conversationUserStateStore.get(params.conversationId); if (!!conversationUserStates && conversationUserStates.conversationId == params.conversationId && !!conversationUserStates.states) { userAddStates = [...conversationUserStates.states]; } else { @@ -761,7 +761,7 @@ }).then(async (result) => { if (result.value) { userAddStates = []; - conversationUserStateStore.reset(); + conversationUserStateStore.resetOne(params.conversationId); } }); } @@ -999,7 +999,7 @@ toggleBigMessageModal()} From d1e7d7d162424231b1babd2da64c7b215f7ab640 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Wed, 4 Sep 2024 16:26:01 -0500 Subject: [PATCH 2/5] clean code --- src/lib/helpers/store.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/helpers/store.js b/src/lib/helpers/store.js index a6b2b37b..a15fc040 100644 --- a/src/lib/helpers/store.js +++ b/src/lib/helpers/store.js @@ -6,7 +6,6 @@ const conversationKey = "conversation"; const conversationUserStatesKey = "conversation_user_states"; const conversationSearchOptionKey = "conversation_search_option"; const conversationUserMessageKey = "conversation_user_messages"; -const conversationHistoryStatesKey = "conversation_history_states"; /** @type {Writable} */ export const userStore = writable({ id: "", full_name: "", expires: 0, token: null }); From 95851099d5536346d59b2165d288624e3f5c1d76 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Wed, 4 Sep 2024 17:42:10 -0500 Subject: [PATCH 3/5] split types --- src/lib/common/AudioGallery.svelte | 2 +- src/lib/common/FileGallery.svelte | 2 +- src/lib/common/MessageFileGallery.svelte | 4 +- src/lib/common/PlainPagination.svelte | 2 +- src/lib/common/TablePagination.svelte | 2 +- .../common/audio-player/AudioPlayer.svelte | 2 +- .../common/audio-player/AudioSpeaker.svelte | 2 +- src/lib/common/audio-player/store.js | 8 +- src/lib/helpers/store.js | 4 +- src/lib/helpers/types/agentTypes.js | 116 ++++++++ src/lib/helpers/types/audioTypes.js | 18 ++ src/lib/helpers/types/commonTypes.js | 34 +++ src/lib/helpers/types/conversationTypes.js | 3 + src/lib/helpers/types/fileTypes.js | 25 ++ src/lib/helpers/types/knowledgeTypes.js | 34 +++ src/lib/helpers/types/pluginTypes.js | 27 ++ src/lib/helpers/types/types.js | 269 +----------------- src/lib/helpers/types/userTypes.js | 19 ++ src/lib/services/agent-service.js | 14 +- src/lib/services/auth-service.js | 4 +- src/lib/services/conversation-service.js | 4 +- src/lib/services/knowledge-base-service.js | 8 +- src/lib/services/llm-provider-service.js | 2 +- src/lib/services/plugin-service.js | 10 +- src/lib/services/router-service.js | 2 +- src/lib/services/task-service.js | 6 +- src/routes/VerticalLayout/Index.svelte | 4 +- src/routes/VerticalLayout/Sidebar.svelte | 2 +- src/routes/chat/+page.svelte | 4 +- .../[agentId]/[conversationId]/+page.svelte | 4 +- .../agent-info/chat-agent-info.svelte | 2 +- .../[conversationId]/chat-box.svelte | 6 +- .../chat-util/chat-file-gallery.svelte | 2 +- .../instant-log/instant-log.svelte | 2 +- src/routes/page/agent/+page.svelte | 10 +- src/routes/page/agent/[agentId]/+page.svelte | 2 +- .../agent/[agentId]/agent-function.svelte | 2 +- .../agent/[agentId]/agent-llm-config.svelte | 4 +- .../agent/[agentId]/agent-overview.svelte | 2 +- .../page/agent/[agentId]/agent-prompt.svelte | 8 +- .../page/agent/[agentId]/agent-routing.svelte | 2 +- .../page/agent/[agentId]/build/+page.svelte | 2 +- .../[agentId]/build/components/Agent.svelte | 2 +- src/routes/page/agent/card-agent.svelte | 2 +- src/routes/page/agent/evaluator/+page.svelte | 8 +- src/routes/page/agent/router/+page.svelte | 8 +- .../page/agent/router/routing-flow.svelte | 6 +- src/routes/page/conversation/+page.svelte | 6 +- .../question-answer/+page.svelte | 4 +- .../vector-item-edit-modal.svelte | 2 +- .../vector-table/vector-item.svelte | 2 +- src/routes/page/plugin/+page.svelte | 10 +- src/routes/page/plugin/plugin-list.svelte | 2 +- src/routes/page/task/+page.svelte | 8 +- .../page/task/[taskId]/execution-flow.svelte | 6 +- src/routes/page/user/me/+page.svelte | 2 +- svelte.config.js | 10 +- 57 files changed, 391 insertions(+), 368 deletions(-) create mode 100644 src/lib/helpers/types/agentTypes.js create mode 100644 src/lib/helpers/types/audioTypes.js create mode 100644 src/lib/helpers/types/commonTypes.js create mode 100644 src/lib/helpers/types/conversationTypes.js create mode 100644 src/lib/helpers/types/fileTypes.js create mode 100644 src/lib/helpers/types/knowledgeTypes.js create mode 100644 src/lib/helpers/types/pluginTypes.js create mode 100644 src/lib/helpers/types/userTypes.js diff --git a/src/lib/common/AudioGallery.svelte b/src/lib/common/AudioGallery.svelte index 4f7a50d3..17c8c079 100644 --- a/src/lib/common/AudioGallery.svelte +++ b/src/lib/common/AudioGallery.svelte @@ -1,7 +1,7 @@ diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index f2b8b679..647ffbaa 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -73,10 +73,10 @@ const screenWidthThreshold = 1024; const maxTextLength = 4096; - /** @type {import('$types').AgentModel} */ + /** @type {import('$agentTypes').AgentModel} */ export let agent; - /** @type {import('$types').UserModel} */ + /** @type {import('$userTypes').UserModel} */ export let currentUser; /** @type {string} */ @@ -129,7 +129,7 @@ /** @type {import('$types').UserStateDetailModel[]} */ let userAddStates = []; - /** @type {import('$types').UserModel} */ + /** @type {import('$userTypes').UserModel} */ let conversationUser; /** @type {boolean} */ diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-util/chat-file-gallery.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-util/chat-file-gallery.svelte index 84956707..efd8d794 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-util/chat-file-gallery.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-util/chat-file-gallery.svelte @@ -6,7 +6,7 @@ /** @type {boolean} */ export let disabled = false; - /** @type {import('$types').TextFileModel[]} */ + /** @type {import('$fileTypes').TextFileModel[]} */ let files = []; const { autoScrollToBottom } = getContext('chat-window-context'); diff --git a/src/routes/chat/[agentId]/[conversationId]/instant-log/instant-log.svelte b/src/routes/chat/[agentId]/[conversationId]/instant-log/instant-log.svelte index 41308329..f53db05d 100644 --- a/src/routes/chat/[agentId]/[conversationId]/instant-log/instant-log.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/instant-log/instant-log.svelte @@ -8,7 +8,7 @@ import ChatAgentInfo from '../agent-info/chat-agent-info.svelte'; import LatestStateLog from './latest-state-log.svelte'; - /** @type {import('$types').AgentModel} */ + /** @type {import('$agentTypes').AgentModel} */ export let agent; /** @type {any[]} */ diff --git a/src/routes/page/agent/+page.svelte b/src/routes/page/agent/+page.svelte index 27082505..c3566729 100644 --- a/src/routes/page/agent/+page.svelte +++ b/src/routes/page/agent/+page.svelte @@ -19,21 +19,21 @@ /** @type {boolean} */ let isLoading = false; - /** @type {import('$types').PagedItems} */ + /** @type {import('$commonTypes').PagedItems} */ let agents = { items: [], count: 0 }; - /** @type {import('$types').AgentFilter} */ + /** @type {import('$agentTypes').AgentFilter} */ const initFilter = { pager: { page: firstPage, size: pageSize, count: 0 } }; - /** @type {import('$types').AgentFilter} */ + /** @type {import('$agentTypes').AgentFilter} */ let filter = { ... initFilter }; - /** @type {import('$types').Pagination} */ + /** @type {import('$commonTypes').Pagination} */ let pager = filter.pager; - /** @type {import('$types').UserModel} */ + /** @type {import('$userTypes').UserModel} */ let user; onMount(async () => { diff --git a/src/routes/page/agent/[agentId]/+page.svelte b/src/routes/page/agent/[agentId]/+page.svelte index fae3824f..24e7525a 100644 --- a/src/routes/page/agent/[agentId]/+page.svelte +++ b/src/routes/page/agent/[agentId]/+page.svelte @@ -20,7 +20,7 @@ import { goto } from '$app/navigation'; - /** @type {import('$types').AgentModel} */ + /** @type {import('$agentTypes').AgentModel} */ let agent; /** @type {any} */ let agentFunctionCmp = null; diff --git a/src/routes/page/agent/[agentId]/agent-function.svelte b/src/routes/page/agent/[agentId]/agent-function.svelte index 487eea62..1480f5fb 100644 --- a/src/routes/page/agent/[agentId]/agent-function.svelte +++ b/src/routes/page/agent/[agentId]/agent-function.svelte @@ -2,7 +2,7 @@ import { JSONEditor, Mode } from 'svelte-jsoneditor'; import { onMount } from 'svelte'; - /** @type {import('$types').AgentModel} */ + /** @type {import('$agentTypes').AgentModel} */ export let agent; export const fetchContent = () => { diff --git a/src/routes/page/agent/[agentId]/agent-llm-config.svelte b/src/routes/page/agent/[agentId]/agent-llm-config.svelte index f05b4a28..8c132d76 100644 --- a/src/routes/page/agent/[agentId]/agent-llm-config.svelte +++ b/src/routes/page/agent/[agentId]/agent-llm-config.svelte @@ -6,10 +6,10 @@ /** @type {string[]} */ let providers = []; - /** @type {import('$types').AgentModel} */ + /** @type {import('$agentTypes').AgentModel} */ export let agent; - /** @type {import('$types').LlmModelSetting[]} */ + /** @type {import('$commonTypes').LlmModelSetting[]} */ let models = []; const lowerLimit = 1; diff --git a/src/routes/page/agent/[agentId]/agent-overview.svelte b/src/routes/page/agent/[agentId]/agent-overview.svelte index b09b1926..0f4e5810 100644 --- a/src/routes/page/agent/[agentId]/agent-overview.svelte +++ b/src/routes/page/agent/[agentId]/agent-overview.svelte @@ -6,7 +6,7 @@ import { AgentType } from '$lib/helpers/enums'; import { getAgentUtilities } from '$lib/services/agent-service'; - /** @type {import('$types').AgentModel} */ + /** @type {import('$agentTypes').AgentModel} */ export let agent; /** @type {string[]} */ diff --git a/src/routes/page/agent/[agentId]/agent-prompt.svelte b/src/routes/page/agent/[agentId]/agent-prompt.svelte index 1e2b5b3e..fa42ed6a 100644 --- a/src/routes/page/agent/[agentId]/agent-prompt.svelte +++ b/src/routes/page/agent/[agentId]/agent-prompt.svelte @@ -4,21 +4,21 @@ import NavBar from '$lib/common/nav-bar/NavBar.svelte'; import NavItem from '$lib/common/nav-bar/NavItem.svelte'; - /** @type {import('$types').AgentModel} */ + /** @type {import('$agentTypes').AgentModel} */ export let agent; const defaultChannel = "default"; - /** @type {import('$types').ChannelInstruction} */ + /** @type {import('$agentTypes').ChannelInstruction} */ const defaultInstruction = { channel: defaultChannel, instruction: '' }; - /** @type {import('$types').ChannelInstruction[]} */ + /** @type {import('$agentTypes').ChannelInstruction[]} */ let local_instructions = []; - /** @type {import('$types').ChannelInstruction} */ + /** @type {import('$agentTypes').ChannelInstruction} */ let selected_instruction = { ...defaultInstruction }; onMount(() => { diff --git a/src/routes/page/agent/[agentId]/agent-routing.svelte b/src/routes/page/agent/[agentId]/agent-routing.svelte index 6ccd49e1..f74ff727 100644 --- a/src/routes/page/agent/[agentId]/agent-routing.svelte +++ b/src/routes/page/agent/[agentId]/agent-routing.svelte @@ -3,7 +3,7 @@ import { directToAgentPage } from "$lib/helpers/utils/common"; import { Card, CardBody, Table } from "@sveltestrap/sveltestrap"; - /** @type {import('$types').AgentModel} */ + /** @type {import('$agentTypes').AgentModel} */ export let agent; diff --git a/src/routes/page/agent/[agentId]/build/+page.svelte b/src/routes/page/agent/[agentId]/build/+page.svelte index eb07e963..fe412165 100644 --- a/src/routes/page/agent/[agentId]/build/+page.svelte +++ b/src/routes/page/agent/[agentId]/build/+page.svelte @@ -10,7 +10,7 @@ let zoom = 0.8; const params = $page.params; - /** @type {import('$types').AgentModel} */ + /** @type {import('$agentTypes').AgentModel} */ let agent; onMount(async () => { agent = await getAgent(params.agentId); diff --git a/src/routes/page/agent/[agentId]/build/components/Agent.svelte b/src/routes/page/agent/[agentId]/build/components/Agent.svelte index e9ee8352..40927deb 100644 --- a/src/routes/page/agent/[agentId]/build/components/Agent.svelte +++ b/src/routes/page/agent/[agentId]/build/components/Agent.svelte @@ -3,7 +3,7 @@ import { Node, Anchor } from 'svelvet'; import { generateInput, generateOutput } from 'svelvet'; - /** @type import('$types').AgentModel */ + /** @type {import('$agentTypes').AgentModel} */ export let agent; /** diff --git a/src/routes/page/agent/card-agent.svelte b/src/routes/page/agent/card-agent.svelte index c11de224..4c1eb703 100644 --- a/src/routes/page/agent/card-agent.svelte +++ b/src/routes/page/agent/card-agent.svelte @@ -5,7 +5,7 @@ import { _ } from 'svelte-i18n'; import { LERNER_ID } from "$lib/helpers/constants"; - /** @type {import('$types').AgentModel[]} */ + /** @type {import('$agentTypes').AgentModel[]} */ export let agents; diff --git a/src/routes/page/agent/evaluator/+page.svelte b/src/routes/page/agent/evaluator/+page.svelte index cbf8497b..49e07d3a 100644 --- a/src/routes/page/agent/evaluator/+page.svelte +++ b/src/routes/page/agent/evaluator/+page.svelte @@ -10,19 +10,19 @@ const firstPage = 1; const pageSize = 12; - /** @type {import('$types').PagedItems} */ + /** @type {import('$commonTypes').PagedItems} */ let agents = { items: [], count: 0 }; - /** @type {import('$types').AgentFilter} */ + /** @type {import('$agentTypes').AgentFilter} */ const initFilter = { pager: { page: firstPage, size: pageSize, count: 0 }, type: "evaluating" }; - /** @type {import('$types').AgentFilter} */ + /** @type {import('$agentTypes').AgentFilter} */ let filter = { ... initFilter }; - /** @type {import('$types').Pagination} */ + /** @type {import('$commonTypes').Pagination} */ let pager = filter.pager; onMount(async () => { diff --git a/src/routes/page/agent/router/+page.svelte b/src/routes/page/agent/router/+page.svelte index 32f22707..be391204 100644 --- a/src/routes/page/agent/router/+page.svelte +++ b/src/routes/page/agent/router/+page.svelte @@ -7,12 +7,12 @@ import { onMount } from 'svelte'; import { _ } from 'svelte-i18n' - /** @type {import('$types').AgentModel[]} */ + /** @type {import('$agentTypes').AgentModel[]} */ let routers; let isRouterNodeSelected = false; let isAgentNodeSelected = false; - /** @type {import('$types').AgentFilter} */ + /** @type {import('$agentTypes').AgentFilter} */ const filter = { pager: { page: 1, size: 10, count: 0 }, disabled: false, @@ -35,13 +35,13 @@ isAgentNodeSelected = false; } - /** @param {import('$types').AgentModel} agent */ + /** @param {import('$agentTypes').AgentModel} agent */ function handleRouterNodeSelected(agent) { isRouterNodeSelected = true; isAgentNodeSelected = true; } - /** @param {import('$types').AgentModel} agent */ + /** @param {import('$agentTypes').AgentModel} agent */ function handleAgentNodeSelected(agent) { isRouterNodeSelected = false; isAgentNodeSelected = true; diff --git a/src/routes/page/agent/router/routing-flow.svelte b/src/routes/page/agent/router/routing-flow.svelte index 0ae11790..06b8b38f 100644 --- a/src/routes/page/agent/router/routing-flow.svelte +++ b/src/routes/page/agent/router/routing-flow.svelte @@ -15,14 +15,14 @@ /** @type {any[]} */ let agentNodes = []; - /** @type {import('$types').AgentFilter} */ + /** @type {import('$agentTypes').AgentFilter} */ const filter = { pager: { page: 1, size: 20, count: 0 }, disabled: false, type: includeTaskAgent ? "task" : "none" }; - /** @type {import('$types').AgentModel[]} */ + /** @type {import('$agentTypes').AgentModel[]} */ export let routers; /** @type {Drawflow} */ @@ -175,7 +175,7 @@ }); } - /** @param {import('$types').AgentModel} router */ + /** @param {import('$agentTypes').AgentModel} router */ function getPlannerName(router) { const planner = router.routing_rules.find(p => p.type == "planner"); return planner?.field ?? "NaviePlanner"; diff --git a/src/routes/page/conversation/+page.svelte b/src/routes/page/conversation/+page.svelte index 8809cd41..6fcc02f1 100644 --- a/src/routes/page/conversation/+page.svelte +++ b/src/routes/page/conversation/+page.svelte @@ -35,7 +35,7 @@ const firstPage = 1; const pageSize = 10; - /** @type {import('$types').PagedItems} */ + /** @type {import('$commonTypes').PagedItems} */ let conversations = { count: 0, items: [] }; /** @type {import('$types').ConversationFilter} */ @@ -46,13 +46,13 @@ /** @type {import('$types').ConversationFilter} */ let filter = { ... initFilter }; - /** @type {import('$types').Pagination} */ + /** @type {import('$commonTypes').Pagination} */ let pager = filter.pager; /** @type {string[]} */ let searchStateStrs = []; - /** @type {import('$types').IdName[]} */ + /** @type {import('$commonTypes').IdName[]} */ let agentOptions = []; /** diff --git a/src/routes/page/knowledge-base/question-answer/+page.svelte b/src/routes/page/knowledge-base/question-answer/+page.svelte index 7682aa28..643835ed 100644 --- a/src/routes/page/knowledge-base/question-answer/+page.svelte +++ b/src/routes/page/knowledge-base/question-answer/+page.svelte @@ -49,7 +49,7 @@ let errorText = "Error"; let confidence = '0.5'; - /** @type {import('$types').KnowledgeSearchViewModel[]} */ + /** @type {import('$knowledgeTypes').KnowledgeSearchViewModel[]} */ let items = []; /** @type {string[]} */ @@ -61,7 +61,7 @@ /** @type {string} */ let editCollection; - /** @type {import('$types').KnowledgeSearchViewModel | null} */ + /** @type {import('$knowledgeTypes').KnowledgeSearchViewModel | null} */ let editItem; /** @type {string} */ diff --git a/src/routes/page/knowledge-base/question-answer/vector-table/vector-item-edit-modal.svelte b/src/routes/page/knowledge-base/question-answer/vector-table/vector-item-edit-modal.svelte index 37b491f3..e31404b8 100644 --- a/src/routes/page/knowledge-base/question-answer/vector-table/vector-item-edit-modal.svelte +++ b/src/routes/page/knowledge-base/question-answer/vector-table/vector-item-edit-modal.svelte @@ -12,7 +12,7 @@ } from "@sveltestrap/sveltestrap"; import _ from "lodash"; - /** @type {import('$types').KnowledgeSearchViewModel | null} */ + /** @type {import('$knowledgeTypes').KnowledgeSearchViewModel | null} */ export let item; /** @type {string} */ diff --git a/src/routes/page/knowledge-base/question-answer/vector-table/vector-item.svelte b/src/routes/page/knowledge-base/question-answer/vector-table/vector-item.svelte index e04d87f5..4d1436e4 100644 --- a/src/routes/page/knowledge-base/question-answer/vector-table/vector-item.svelte +++ b/src/routes/page/knowledge-base/question-answer/vector-table/vector-item.svelte @@ -7,7 +7,7 @@ const svelteDispatch = createEventDispatcher(); - /** @type {import('$types').KnowledgeSearchViewModel} */ + /** @type {import('$knowledgeTypes').KnowledgeSearchViewModel} */ export let item; /** @type {string} */ diff --git a/src/routes/page/plugin/+page.svelte b/src/routes/page/plugin/+page.svelte index e46ec5ca..d8ac0563 100644 --- a/src/routes/page/plugin/+page.svelte +++ b/src/routes/page/plugin/+page.svelte @@ -11,18 +11,18 @@ const firstPage = 1; const pageSize = 12; - /** @type {import('$types').PagedItems} */ + /** @type {import('$commonTypes').PagedItems} */ let plugins = { items: [], count: 0 }; - /** @type {import('$types').PluginFilter} */ + /** @type {import('$pluginTypes').PluginFilter} */ const initFilter = { pager: { page: firstPage, size: pageSize, count: 0 } }; - /** @type {import('$types').PluginFilter} */ + /** @type {import('$pluginTypes').PluginFilter} */ let filter = { ... initFilter }; - /** @type {import('$types').Pagination} */ + /** @type {import('$commonTypes').Pagination} */ let pager = filter.pager; onMount(async () => { @@ -77,7 +77,7 @@ getPagedPlugins(); } - /** @param {import('$types').PluginDefModel} plugin */ + /** @param {import('$pluginTypes').PluginDefModel} plugin */ function getIconUrl(plugin) { if (plugin.is_core) { return 'images/logo.png'; diff --git a/src/routes/page/plugin/plugin-list.svelte b/src/routes/page/plugin/plugin-list.svelte index 52edd567..78c39778 100644 --- a/src/routes/page/plugin/plugin-list.svelte +++ b/src/routes/page/plugin/plugin-list.svelte @@ -10,7 +10,7 @@ import { installPlugin, removePlugin } from '$lib/services/plugin-service'; import Swal from 'sweetalert2'; - /** @type {import('$types').PluginDefModel[]} */ + /** @type {import('$pluginTypes').PluginDefModel[]} */ export let plugins; /** diff --git a/src/routes/page/task/+page.svelte b/src/routes/page/task/+page.svelte index 8923c663..400c288e 100644 --- a/src/routes/page/task/+page.svelte +++ b/src/routes/page/task/+page.svelte @@ -42,18 +42,18 @@ } }; - /** @type {import('$types').PagedItems} */ + /** @type {import('$commonTypes').PagedItems} */ let tasks = { count: 0, items: [] }; - /** @type {import('$types').AgentTaskFilter} */ + /** @type {import('$agentTypes').AgentTaskFilter} */ const initFilter = { pager: { page: firstPage, size: pageSize, count: 0 } }; - /** @type {import('$types').AgentTaskFilter} */ + /** @type {import('$agentTypes').AgentTaskFilter} */ let filter = { ... initFilter }; - /** @type {import('$types').Pagination} */ + /** @type {import('$commonTypes').Pagination} */ let pager = filter.pager; onMount(async () => { diff --git a/src/routes/page/task/[taskId]/execution-flow.svelte b/src/routes/page/task/[taskId]/execution-flow.svelte index 43945d9e..334b34ea 100644 --- a/src/routes/page/task/[taskId]/execution-flow.svelte +++ b/src/routes/page/task/[taskId]/execution-flow.svelte @@ -2,7 +2,7 @@ import Drawflow from 'drawflow'; import 'drawflow/dist/drawflow.min.css'; import '$lib/drawflow/drawflow.css'; - import { onMount, createEventDispatcher } from 'svelte'; + import { onMount } from 'svelte'; import { newConversation } from '$lib/services/conversation-service'; import { conversationStore } from '$lib/helpers/store.js'; import { getAgentTaskDetail } from '$lib/services/task-service'; @@ -12,10 +12,10 @@ import { page } from '$app/stores'; import { replaceNewLine } from '$lib/helpers/http'; - /** @type {import('$types').AgentTaskModel} */ + /** @type {import('$agentTypes').AgentTaskModel} */ let task; - /** @type {import('$types').AgentTemplate[]} */ + /** @type {import('$agentTypes').AgentTemplate[]} */ let taskNodes = []; /** @type {Drawflow} */ diff --git a/src/routes/page/user/me/+page.svelte b/src/routes/page/user/me/+page.svelte index ce2f512a..89d0e02d 100644 --- a/src/routes/page/user/me/+page.svelte +++ b/src/routes/page/user/me/+page.svelte @@ -11,7 +11,7 @@ import { PUBLIC_SERVICE_URL } from '$env/static/public'; import { buildUrl } from '$lib/helpers/utils/common'; - /** @type {import('$types').UserModel} */ + /** @type {import('$userTypes').UserModel} */ let currentUser; let isLoading = false; diff --git a/svelte.config.js b/svelte.config.js index 5d2ae226..f446b5e7 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -7,7 +7,15 @@ const config = { // preprocess: vitePreprocess(), kit: { alias: { - $types: './src/lib/helpers/types/types.js' + $types: './src/lib/helpers/types/types.js', + $agentTypes: './src/lib/helpers/types/agentTypes.js', + $conversationTypes: './src/lib/helpers/types/conversationTypes.js', + $knowledgeTypes: './src/lib/helpers/types/knowledgeTypes.js', + $fileTypes: './src/lib/helpers/types/fileTypes.js', + $audioTypes: './src/lib/helpers/types/audioTypes.js', + $userTypes: './src/lib/helpers/types/userTypes.js', + $commonTypes: './src/lib/helpers/types/commonTypes.js', + $pluginTypes: './src/lib/helpers/types/pluginTypes.js', }, // for static deployment From 095d5731ddc2ab36c49c550da7a62c4df90dd51f Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Wed, 4 Sep 2024 17:47:02 -0500 Subject: [PATCH 4/5] merge conversation types --- src/lib/common/StateModal.svelte | 4 +- src/lib/helpers/store.js | 4 +- src/lib/helpers/types/conversationTypes.js | 307 +++++++++++++++++ src/lib/helpers/types/types.js | 310 ------------------ src/lib/helpers/utils/gallery.js | 2 +- src/lib/services/conversation-service.js | 14 +- src/lib/services/instruct-service.js | 2 +- src/lib/services/logging-service.js | 4 +- src/lib/services/signalr-service.js | 20 +- src/lib/services/web-speech.js | 2 +- src/routes/chat/[agentId]/+page.svelte | 2 +- .../[conversationId]/chat-box.svelte | 56 ++-- .../instant-log/instant-log.svelte | 2 +- .../instant-log/latest-state-log.svelte | 2 +- .../persist-log/content-log-element.svelte | 2 +- .../persist-log/persist-log.svelte | 6 +- .../rich-content/rich-content.svelte | 2 +- src/routes/page/conversation/+page.svelte | 8 +- .../[conversationId]/+page.svelte | 2 +- .../conv-dialog-element.svelte | 2 +- .../[conversationId]/conv-dialogs.svelte | 6 +- .../[conversationId]/conv-overview.svelte | 2 +- .../[conversationId]/conv-states.svelte | 2 +- .../page/task/[taskId]/execution-flow.svelte | 4 +- svelte.config.js | 3 +- 25 files changed, 383 insertions(+), 387 deletions(-) delete mode 100644 src/lib/helpers/types/types.js diff --git a/src/lib/common/StateModal.svelte b/src/lib/common/StateModal.svelte index efa01644..ec5addf6 100644 --- a/src/lib/common/StateModal.svelte +++ b/src/lib/common/StateModal.svelte @@ -41,10 +41,10 @@ export let validateValue = true; export let requireActiveRounds = false; - /** @type {import('$types').UserStateDetailModel[]} */ + /** @type {import('$conversationTypes').UserStateDetailModel[]} */ export let states = []; - /** @type {import('$types').UserStateDetailModel} */ + /** @type {import('$conversationTypes').UserStateDetailModel} */ const defaultState = { key: { data: '', isValid: true }, value: { data: '', isValid: true }, diff --git a/src/lib/helpers/store.js b/src/lib/helpers/store.js index d8972d0f..efdd91f6 100644 --- a/src/lib/helpers/store.js +++ b/src/lib/helpers/store.js @@ -34,11 +34,11 @@ userStore.subscribe(value => { }); -/** @type {Writable}*/ +/** @type {Writable}*/ export const conversationStore = writable({}); /** - * @returns {Writable} + * @returns {Writable} */ export function getConversationStore() { if (browser) { diff --git a/src/lib/helpers/types/conversationTypes.js b/src/lib/helpers/types/conversationTypes.js index 5dfdbd44..52027e6e 100644 --- a/src/lib/helpers/types/conversationTypes.js +++ b/src/lib/helpers/types/conversationTypes.js @@ -1,3 +1,310 @@ +/** + * @typedef {Object} InstructMessageModel + * @property {string} [instruction] - User provided prompt instead of predefined template. + * @property {string} [template] - The template name. + */ +/** + * @typedef {Object} MessageConfig + * @property {string} [taskId] - Optional task id. + */ +/** + * @typedef {Object} ConversationFilter + * @property {import('$commonTypes').Pagination} pager - Pagination + * @property {string?} [agentId] - The agent id. + * @property {string?} [channel] - The conversation channel. + * @property {string?} [status] - The conversation status. + * @property {string?} [taskId] - The task id. + * @property {import('$commonTypes').KeyValuePair[]} [states] - The conversation status. + */ + +/** + * @typedef {Object} ConversationModel + * @property {string} id - The conversation id. + * @property {string} title - The conversation title. + * @property {import('$userTypes').UserModel} user - The conversation initializer. + * @property {string} agent_id - The conversation agent id. + * @property {string} agent_name - The conversation entry agent name. + * @property {string} channel - The conversation status. + * @property {string} [task_id] - Optional task id. + * @property {string} status - The conversation status. + * @property {Object[]} states - The conversation states. + * @property {Date} updated_time - The conversation updated time. + * @property {Date} created_time - The conversation created time. + */ + + +/** + * @interface + * @class + * @classdesc A basic rich content interface. + */ +function IRichContent() {} + +/** + * The type of the rich content. + * + * @name rich_type + * @type {string} + * @instance + */ +IRichContent.prototype.rich_type; + +/** + * The text of the rich content. + * + * @name text + * @type {string} + * @instance + */ +IRichContent.prototype.text; + +/** + * The options of the rich content. + * + * @name options + * @type {any[]} + * @instance + */ +IRichContent.prototype.options; + +/** + * The buttons of the rich content. + * + * @name buttons + * @type {any[]} + * @instance + */ +IRichContent.prototype.buttons; + +/** + * The elements of the rich content. + * + * @name elements + * @type {any[]} + * @instance + */ +IRichContent.prototype.elements; + +/** + * The quick replies of the rich content. + * + * @name quick_replies + * @type {any[]} + * @instance + */ +IRichContent.prototype.quick_replies; + +/** + * @typedef {Object} TextMessage + * @property {string} text + * @property {string} rich_type + */ + +/** + * @typedef {Object} QuickReplyElement + * @property {string} content_type + * @property {string} title + * @property {string} payload + * @property {string} image_url + */ + +/** + * @typedef {Object} QuickReplyMessage + * @property {string} text + * @property {string} rich_type + * @property {QuickReplyElement[]} quick_replies + */ + +/** + * @typedef {Object} RichContent + * @property {string} messaging_type + * @property {boolean} fill_postback + * @property {string} editor + * @property {string?} [editor_attributes] + * @property {IRichContent} message + */ + +/** + * @typedef {Object} ChatResponseModel + * @property {string} conversation_id - The conversation id. + * @property {import('$userTypes').UserModel} sender - The message sender. + * @property {string} message_id - The message id. + * @property {string} text - The message content. + * @property {string} editor - The message editor. + * @property {string} function - The function name. + * @property {RichContent} rich_content - Rich content. + * @property {string} post_action_disclaimer - The message disclaimer. + * @property {string} data - The message data. + * @property {Date} created_at - The message sent time. + * @property {boolean} has_message_files + * @property {boolean} is_chat_message + */ + +/** + * @typedef {Object} ConversationContentLogModel + * @property {string} conversation_id - The conversation id. + * @property {string} message_id - The message id. + * @property {string} name - The sender name. + * @property {string} agent_id = The agent id. + * @property {string} role - The sender role. + * @property {string} source - The log source. + * @property {string} content - The log content. + * @property {Date} created_at - The log sent time. + */ + +/** + * @typedef {Object} ConversationStateLogModel + * @property {string} conversation_id - The conversation id. + * @property {string} message_id - The message id. + * @property {Object} states - The states content. + * @property {Date} created_at - The log sent time. + */ + +/** + * @typedef {Object} MessageStateLogModel + * @property {string} conversation_id - The conversation id. + * @property {string} message_id - The message id. + * @property {string} before_value - The value before change. + * @property {number?} before_active_rounds - The state active rounds before change. + * @property {string} after_value - The value after change. + * @property {number?} after_active_rounds - The state active rounds after change. + * @property {string} data_type - The state value data type. + * @property {string} source - The state source. + * @property {Date} created_at - The log sent time. + */ + +/** + * @typedef {Object} AgentQueueLogModel + * @property {string} conversation_id - The conversation id. + * @property {string} log - The log content. + * @property {Date} created_at - The log sent time. + */ + +/** + * Conversation states added by user + * + * @typedef {Object} UserStateDetailModel + * @property {{data: string, isValid: boolean}} key - The state key. + * @property {{data: string, isValid: boolean}} value - The state value. + * @property {{data: number, isValid: boolean}} active_rounds - The state active rounds. + */ + +/** + * Conversation states added by user + * + * @typedef {Object} ConversationUserStateModel + * @property {string} conversationId - The conversation id. + * @property {UserStateDetailModel[]} states - The states added by user. + */ + + +/** + * Conversation sender action + * + * @typedef {Object} ConversationSenderActionModel + * @property {string} conversation_id - The conversation id. + * @property {number} sender_action - The sender action. + * @property {string} [indication] - The function indication. + */ + +/** + * Conversation message deleted + * + * @typedef {Object} ConversationMessageDeleteModel + * @property {string} conversation_id - The conversation id. + * @property {string} message_id - The message id. + */ + +/** + * Conversation postback + * + * @typedef {Object} Postback + * @property {string?} functionName - The function name. + * @property {string?} payload - The payload. + * @property {string?} parentId - The parent message id. + */ + +/** + * Conversation send message data + * + * @typedef {Object} MessageData + * @property {string?} [truncateMsgId] - The truncated message. + * @property {string?} [inputMessageId] - The input message. + * @property {string[]?} [states] - The states input by user. + * @property {Postback?} [postback] - The parent message id. + * @property {string?} [payload] - The payload message. + */ + + + + +/** + * Invoked when a new conersation is created. + * This callback type is called `requestCallback` and is displayed as a global symbol. + * + * @callback OnConversationInitialized + * @param {ConversationModel} conversation + */ + +/** + * Invoked when message is received form chatHub. + * This callback type is called `requestCallback` and is displayed as a global symbol. + * + * @callback OnMessageReceived + * @param {ChatResponseModel} message + */ + +/** + * Invoked when speech to text is detected. + * + * @callback OnSpeechToTextDetected + * @param {string} text + */ + +/** + * Conversation content log + * + * @callback OnConversationContentLogReceived + * @param {ConversationContentLogModel} log + */ + +/** + * Conversation state log + * + * @callback OnConversationStateLogGenerated + * @param {ConversationStateLogModel} log + */ + +/** + * Conversation state change log + * + * @callback OnStateChangeGenerated + * @param {MessageStateLogModel} log + */ + +/** + * Agent queue changed log + * + * @callback OnAgentQueueChanged + * @param {AgentQueueLogModel} log + */ + +/** + * Conversation sender action + * + * @callback OnSenderActionGenerated + * @param {ConversationSenderActionModel} data + */ + +/** + * Conversation message deleted + * + * @callback OnConversationMessageDeleted + * @param {ConversationMessageDeleteModel} data + */ + +// having to export an empty object here is annoying, +// but required for vscode to pass on your types. export default {}; \ No newline at end of file diff --git a/src/lib/helpers/types/types.js b/src/lib/helpers/types/types.js deleted file mode 100644 index 52027e6e..00000000 --- a/src/lib/helpers/types/types.js +++ /dev/null @@ -1,310 +0,0 @@ -/** - * @typedef {Object} InstructMessageModel - * @property {string} [instruction] - User provided prompt instead of predefined template. - * @property {string} [template] - The template name. - */ - -/** - * @typedef {Object} MessageConfig - * @property {string} [taskId] - Optional task id. - */ - -/** - * @typedef {Object} ConversationFilter - * @property {import('$commonTypes').Pagination} pager - Pagination - * @property {string?} [agentId] - The agent id. - * @property {string?} [channel] - The conversation channel. - * @property {string?} [status] - The conversation status. - * @property {string?} [taskId] - The task id. - * @property {import('$commonTypes').KeyValuePair[]} [states] - The conversation status. - */ - -/** - * @typedef {Object} ConversationModel - * @property {string} id - The conversation id. - * @property {string} title - The conversation title. - * @property {import('$userTypes').UserModel} user - The conversation initializer. - * @property {string} agent_id - The conversation agent id. - * @property {string} agent_name - The conversation entry agent name. - * @property {string} channel - The conversation status. - * @property {string} [task_id] - Optional task id. - * @property {string} status - The conversation status. - * @property {Object[]} states - The conversation states. - * @property {Date} updated_time - The conversation updated time. - * @property {Date} created_time - The conversation created time. - */ - - -/** - * @interface - * @class - * @classdesc A basic rich content interface. - */ -function IRichContent() {} - -/** - * The type of the rich content. - * - * @name rich_type - * @type {string} - * @instance - */ -IRichContent.prototype.rich_type; - -/** - * The text of the rich content. - * - * @name text - * @type {string} - * @instance - */ -IRichContent.prototype.text; - -/** - * The options of the rich content. - * - * @name options - * @type {any[]} - * @instance - */ -IRichContent.prototype.options; - -/** - * The buttons of the rich content. - * - * @name buttons - * @type {any[]} - * @instance - */ -IRichContent.prototype.buttons; - -/** - * The elements of the rich content. - * - * @name elements - * @type {any[]} - * @instance - */ -IRichContent.prototype.elements; - -/** - * The quick replies of the rich content. - * - * @name quick_replies - * @type {any[]} - * @instance - */ -IRichContent.prototype.quick_replies; - -/** - * @typedef {Object} TextMessage - * @property {string} text - * @property {string} rich_type - */ - -/** - * @typedef {Object} QuickReplyElement - * @property {string} content_type - * @property {string} title - * @property {string} payload - * @property {string} image_url - */ - -/** - * @typedef {Object} QuickReplyMessage - * @property {string} text - * @property {string} rich_type - * @property {QuickReplyElement[]} quick_replies - */ - -/** - * @typedef {Object} RichContent - * @property {string} messaging_type - * @property {boolean} fill_postback - * @property {string} editor - * @property {string?} [editor_attributes] - * @property {IRichContent} message - */ - -/** - * @typedef {Object} ChatResponseModel - * @property {string} conversation_id - The conversation id. - * @property {import('$userTypes').UserModel} sender - The message sender. - * @property {string} message_id - The message id. - * @property {string} text - The message content. - * @property {string} editor - The message editor. - * @property {string} function - The function name. - * @property {RichContent} rich_content - Rich content. - * @property {string} post_action_disclaimer - The message disclaimer. - * @property {string} data - The message data. - * @property {Date} created_at - The message sent time. - * @property {boolean} has_message_files - * @property {boolean} is_chat_message - */ - -/** - * @typedef {Object} ConversationContentLogModel - * @property {string} conversation_id - The conversation id. - * @property {string} message_id - The message id. - * @property {string} name - The sender name. - * @property {string} agent_id = The agent id. - * @property {string} role - The sender role. - * @property {string} source - The log source. - * @property {string} content - The log content. - * @property {Date} created_at - The log sent time. - */ - -/** - * @typedef {Object} ConversationStateLogModel - * @property {string} conversation_id - The conversation id. - * @property {string} message_id - The message id. - * @property {Object} states - The states content. - * @property {Date} created_at - The log sent time. - */ - -/** - * @typedef {Object} MessageStateLogModel - * @property {string} conversation_id - The conversation id. - * @property {string} message_id - The message id. - * @property {string} before_value - The value before change. - * @property {number?} before_active_rounds - The state active rounds before change. - * @property {string} after_value - The value after change. - * @property {number?} after_active_rounds - The state active rounds after change. - * @property {string} data_type - The state value data type. - * @property {string} source - The state source. - * @property {Date} created_at - The log sent time. - */ - -/** - * @typedef {Object} AgentQueueLogModel - * @property {string} conversation_id - The conversation id. - * @property {string} log - The log content. - * @property {Date} created_at - The log sent time. - */ - -/** - * Conversation states added by user - * - * @typedef {Object} UserStateDetailModel - * @property {{data: string, isValid: boolean}} key - The state key. - * @property {{data: string, isValid: boolean}} value - The state value. - * @property {{data: number, isValid: boolean}} active_rounds - The state active rounds. - */ - -/** - * Conversation states added by user - * - * @typedef {Object} ConversationUserStateModel - * @property {string} conversationId - The conversation id. - * @property {UserStateDetailModel[]} states - The states added by user. - */ - - -/** - * Conversation sender action - * - * @typedef {Object} ConversationSenderActionModel - * @property {string} conversation_id - The conversation id. - * @property {number} sender_action - The sender action. - * @property {string} [indication] - The function indication. - */ - -/** - * Conversation message deleted - * - * @typedef {Object} ConversationMessageDeleteModel - * @property {string} conversation_id - The conversation id. - * @property {string} message_id - The message id. - */ - -/** - * Conversation postback - * - * @typedef {Object} Postback - * @property {string?} functionName - The function name. - * @property {string?} payload - The payload. - * @property {string?} parentId - The parent message id. - */ - -/** - * Conversation send message data - * - * @typedef {Object} MessageData - * @property {string?} [truncateMsgId] - The truncated message. - * @property {string?} [inputMessageId] - The input message. - * @property {string[]?} [states] - The states input by user. - * @property {Postback?} [postback] - The parent message id. - * @property {string?} [payload] - The payload message. - */ - - - - -/** - * Invoked when a new conersation is created. - * This callback type is called `requestCallback` and is displayed as a global symbol. - * - * @callback OnConversationInitialized - * @param {ConversationModel} conversation - */ - -/** - * Invoked when message is received form chatHub. - * This callback type is called `requestCallback` and is displayed as a global symbol. - * - * @callback OnMessageReceived - * @param {ChatResponseModel} message - */ - -/** - * Invoked when speech to text is detected. - * - * @callback OnSpeechToTextDetected - * @param {string} text - */ - -/** - * Conversation content log - * - * @callback OnConversationContentLogReceived - * @param {ConversationContentLogModel} log - */ - -/** - * Conversation state log - * - * @callback OnConversationStateLogGenerated - * @param {ConversationStateLogModel} log - */ - -/** - * Conversation state change log - * - * @callback OnStateChangeGenerated - * @param {MessageStateLogModel} log - */ - -/** - * Agent queue changed log - * - * @callback OnAgentQueueChanged - * @param {AgentQueueLogModel} log - */ - -/** - * Conversation sender action - * - * @callback OnSenderActionGenerated - * @param {ConversationSenderActionModel} data - */ - -/** - * Conversation message deleted - * - * @callback OnConversationMessageDeleted - * @param {ConversationMessageDeleteModel} data - */ - -// having to export an empty object here is annoying, -// but required for vscode to pass on your types. -export default {}; \ No newline at end of file diff --git a/src/lib/helpers/utils/gallery.js b/src/lib/helpers/utils/gallery.js index 64965c7b..8d65bb2d 100644 --- a/src/lib/helpers/utils/gallery.js +++ b/src/lib/helpers/utils/gallery.js @@ -1,7 +1,7 @@ import { EditorType, ElementType } from '../enums'; /** - * @param {import('$types').ChatResponseModel?} message + * @param {import('$conversationTypes').ChatResponseModel?} message */ export function loadFileGallery(message) { return message?.rich_content?.editor === EditorType.File diff --git a/src/lib/services/conversation-service.js b/src/lib/services/conversation-service.js index ae4fb175..04bc25a1 100644 --- a/src/lib/services/conversation-service.js +++ b/src/lib/services/conversation-service.js @@ -6,8 +6,8 @@ import { conversationUserStateStore } from '$lib/helpers/store.js'; /** * New conversation * @param {string} agentId - * @param {Promise} [config] - * @returns {Promise} + * @param {Promise} [config] + * @returns {Promise} */ export async function newConversation(agentId, config) { let url = replaceUrl(endpoints.conversationInitUrl, {agentId: agentId}); @@ -18,7 +18,7 @@ export async function newConversation(agentId, config) { /** * Get conversation detail * @param {string} id - * @returns {Promise} + * @returns {Promise} */ export async function getConversation(id) { let url = replaceUrl(endpoints.conversationDetailUrl, {conversationId: id}); @@ -39,8 +39,8 @@ export async function getConversationUser(id) { /** * Get conversation list - * @param {import('$types').ConversationFilter} filter - * @returns {Promise>} + * @param {import('$conversationTypes').ConversationFilter} filter + * @returns {Promise>} */ export async function getConversations(filter) { let url = endpoints.conversationsUrl; @@ -74,7 +74,7 @@ export async function deleteConversation(conversationId) { /** * Get dialog history * @param {string} conversationId - * @returns {Promise} + * @returns {Promise} */ export async function GetDialogs(conversationId) { let url = replaceUrl(endpoints.dialogsUrl, {conversationId: conversationId}); @@ -87,7 +87,7 @@ export async function GetDialogs(conversationId) { * @param {string} agentId - The agent id * @param {string} conversationId - The conversation id * @param {string} text - The text message sent to CSR - * @param {import('$types').MessageData?} data - Additional data + * @param {import('$conversationTypes').MessageData?} data - Additional data */ export async function sendMessageToHub(agentId, conversationId, text, data = null) { console.log(data); diff --git a/src/lib/services/instruct-service.js b/src/lib/services/instruct-service.js index a0c243f5..b8c9963c 100644 --- a/src/lib/services/instruct-service.js +++ b/src/lib/services/instruct-service.js @@ -5,7 +5,7 @@ import axios from 'axios'; /** * Execute agent instruction by template or user provided prompt. * @param {string} agentId - * @param {import('$types').InstructMessageModel} instruction + * @param {import('$conversationTypes').InstructMessageModel} instruction */ export async function executeAgentInstruction(agentId, instruction) { let url = replaceUrl(endpoints.instructCompletionUrl, {agentId: agentId}); diff --git a/src/lib/services/logging-service.js b/src/lib/services/logging-service.js index 7d2855ee..bed88b62 100644 --- a/src/lib/services/logging-service.js +++ b/src/lib/services/logging-service.js @@ -24,7 +24,7 @@ export async function getFullLog() { /** * Get conversation content log * @param {string} conversationId - * @returns {Promise} + * @returns {Promise} */ export async function GetContentLogs(conversationId) { let url = replaceUrl(endpoints.loggingContentLogUrl, {conversationId: conversationId}); @@ -35,7 +35,7 @@ export async function GetContentLogs(conversationId) { /** * Get conversation state log * @param {string} conversationId - * @returns {Promise} + * @returns {Promise} */ export async function GetStateLogs(conversationId) { let url = replaceUrl(endpoints.loggingStateLogUrl, {conversationId: conversationId}); diff --git a/src/lib/services/signalr-service.js b/src/lib/services/signalr-service.js index 599e85d4..1d9a52fa 100644 --- a/src/lib/services/signalr-service.js +++ b/src/lib/services/signalr-service.js @@ -9,34 +9,34 @@ let connection; // create a SignalR service object that exposes methods to interact with the hub export const signalr = { - /** @type {import('$types').OnConversationInitialized} */ + /** @type {import('$conversationTypes').OnConversationInitialized} */ onConversationInitFromClient: () => {}, - /** @type {import('$types').OnMessageReceived} */ + /** @type {import('$conversationTypes').OnMessageReceived} */ onMessageReceivedFromClient: () => {}, - /** @type {import('$types').OnMessageReceived} */ + /** @type {import('$conversationTypes').OnMessageReceived} */ onMessageReceivedFromCsr: () => {}, - /** @type {import('$types').OnMessageReceived} */ + /** @type {import('$conversationTypes').OnMessageReceived} */ onMessageReceivedFromAssistant: () => {}, - /** @type {import('$types').OnConversationContentLogReceived} */ + /** @type {import('$conversationTypes').OnConversationContentLogReceived} */ onConversationContentLogGenerated: () => {}, - /** @type {import('$types').OnConversationStateLogGenerated} */ + /** @type {import('$conversationTypes').OnConversationStateLogGenerated} */ onConversationStateLogGenerated: () => {}, - /** @type {import('$types').OnStateChangeGenerated} */ + /** @type {import('$conversationTypes').OnStateChangeGenerated} */ onStateChangeGenerated: () => {}, - /** @type {import('$types').OnAgentQueueChanged} */ + /** @type {import('$conversationTypes').OnAgentQueueChanged} */ onAgentQueueChanged: () => {}, - /** @type {import('$types').OnSenderActionGenerated} */ + /** @type {import('$conversationTypes').OnSenderActionGenerated} */ onSenderActionGenerated: () => {}, - /** @type {import('$types').OnConversationMessageDeleted} */ + /** @type {import('$conversationTypes').OnConversationMessageDeleted} */ onConversationMessageDeleted: () => {}, // start the connection diff --git a/src/lib/services/web-speech.js b/src/lib/services/web-speech.js index 7ed502c2..2f8a4b3d 100644 --- a/src/lib/services/web-speech.js +++ b/src/lib/services/web-speech.js @@ -21,7 +21,7 @@ export const SPEECH_VOICES = [ ]; export const webSpeech = { - /** @type {import('$types').OnSpeechToTextDetected} */ + /** @type {import('$conversationTypes').OnSpeechToTextDetected} */ onSpeechToTextDetected: () => {}, start() { diff --git a/src/routes/chat/[agentId]/+page.svelte b/src/routes/chat/[agentId]/+page.svelte index d3301b40..15edda43 100644 --- a/src/routes/chat/[agentId]/+page.svelte +++ b/src/routes/chat/[agentId]/+page.svelte @@ -12,7 +12,7 @@ const params = $page.params; - /** @type {import('$types').ConversationModel} */ + /** @type {import('$conversationTypes').ConversationModel} */ let conversation; let conversationId = "undefined"; diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index 647ffbaa..02b35d97 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -100,33 +100,33 @@ let scrollbars = []; let microphoneIcon = "microphone-off"; - /** @type {import('$types').ChatResponseModel?} */ + /** @type {import('$conversationTypes').ChatResponseModel?} */ let lastBotMsg; - /** @type {import('$types').ChatResponseModel?} */ + /** @type {import('$conversationTypes').ChatResponseModel?} */ let lastMsg; - /** @type {import('$types').ChatResponseModel[]} */ + /** @type {import('$conversationTypes').ChatResponseModel[]} */ let dialogs = []; /** @type {{ [s: string]: any; }} */ let groupedDialogs = []; - /** @type {import('$types').ConversationContentLogModel[]} */ + /** @type {import('$conversationTypes').ConversationContentLogModel[]} */ let contentLogs = []; - /** @type {import('$types').ConversationStateLogModel[]} */ + /** @type {import('$conversationTypes').ConversationStateLogModel[]} */ let convStateLogs = []; - /** @type {import('$types').ConversationStateLogModel?} */ + /** @type {import('$conversationTypes').ConversationStateLogModel?} */ let latestStateLog; - /** @type {import('$types').MessageStateLogModel[]} */ + /** @type {import('$conversationTypes').MessageStateLogModel[]} */ let msgStateLogs = []; - /** @type {import('$types').AgentQueueLogModel[]} */ + /** @type {import('$conversationTypes').AgentQueueLogModel[]} */ let agentQueueLogs = []; - /** @type {import('$types').UserStateDetailModel[]} */ + /** @type {import('$conversationTypes').UserStateDetailModel[]} */ let userAddStates = []; /** @type {import('$userTypes').UserModel} */ @@ -212,7 +212,7 @@ resizeChatWindow(); } - /** @param {import('$types').ChatResponseModel[]} dialogs */ + /** @param {import('$conversationTypes').ChatResponseModel[]} dialogs */ function initUserSentMessages(dialogs) { const curConvMessages = dialogs?.filter(x => USER_SENDERS.includes(x.sender?.role || '')).map(x => { return { @@ -262,7 +262,7 @@ return messages?.slice(-messageLimit) || []; } - /** @param {import('$types').ChatResponseModel[]} dialogs */ + /** @param {import('$conversationTypes').ChatResponseModel[]} dialogs */ function findLastBotMessage(dialogs) { const lastMsg = dialogs.slice(-1)[0]; return BOT_SENDERS.includes(lastMsg?.sender?.role || '') ? lastMsg : null; @@ -288,7 +288,7 @@ }) } - /** @param {import('$types').ChatResponseModel[]} dialogs */ + /** @param {import('$conversationTypes').ChatResponseModel[]} dialogs */ function assignMessageDisclaimer(dialogs) { if (!!!dialogs) return null; @@ -311,7 +311,7 @@ } } - /** @param {import('$types').ChatResponseModel[]} dialogs */ + /** @param {import('$conversationTypes').ChatResponseModel[]} dialogs */ function groupDialogs(dialogs) { if (!!!dialogs) return []; const format = 'MMM D, YYYY'; @@ -332,7 +332,7 @@ } - /** @param {import('$types').ChatResponseModel} message */ + /** @param {import('$conversationTypes').ChatResponseModel} message */ function onMessageReceivedFromClient(message) { dialogs.push({ ...message, @@ -342,7 +342,7 @@ text = ""; } - /** @param {import('$types').ChatResponseModel} message */ + /** @param {import('$conversationTypes').ChatResponseModel} message */ function onMessageReceivedFromCsr(message) { dialogs.push({ ...message, @@ -351,7 +351,7 @@ refresh(); } - /** @param {import('$types').ChatResponseModel} message */ + /** @param {import('$conversationTypes').ChatResponseModel} message */ function onMessageReceivedFromAssistant(message) { // webSpeech.utter(message.text); dialogs.push({ @@ -361,14 +361,14 @@ refresh(); } - /** @param {import('$types').ConversationContentLogModel} log */ + /** @param {import('$conversationTypes').ConversationContentLogModel} log */ function onConversationContentLogGenerated(log) { if (!isLoadPersistLog) return; contentLogs.push({ ...log }); contentLogs = contentLogs.map(x => { return { ...x }; }); } - /** @param {import('$types').ConversationStateLogModel} log */ + /** @param {import('$conversationTypes').ConversationStateLogModel} log */ function onConversationStateLogGenerated(log) { if (!isLoadPersistLog) return; @@ -377,7 +377,7 @@ convStateLogs = convStateLogs.map(x => { return { ...x }; }); } - /** @param {import('$types').MessageStateLogModel} log */ + /** @param {import('$conversationTypes').MessageStateLogModel} log */ function onStateChangeGenerated(log) { if (!isLoadInstantLog || log == null) return; @@ -385,7 +385,7 @@ msgStateLogs = msgStateLogs.map(x => { return { ...x }; }); } - /** @param {import('$types').AgentQueueLogModel} log */ + /** @param {import('$conversationTypes').AgentQueueLogModel} log */ function onAgentQueueChanged(log) { if (!isLoadInstantLog || log == null) return; @@ -393,7 +393,7 @@ agentQueueLogs = agentQueueLogs.map(x => { return { ...x }; }); } - /** @param {import('$types').ConversationSenderActionModel} data */ + /** @param {import('$conversationTypes').ConversationSenderActionModel} data */ function onSenderActionGenerated(data) { if (data?.sender_action == SenderAction.TypingOn) { isThinking = true; @@ -405,7 +405,7 @@ } } - /** @param {import('$types').ConversationMessageDeleteModel} data */ + /** @param {import('$conversationTypes').ConversationMessageDeleteModel} data */ function onConversationMessageDeleted(data) { if (!!!data?.message_id) return; truncateDialogs(data.message_id); @@ -424,7 +424,7 @@ /** * @param {string} msgText - * @param {import('$types').MessageData?} data + * @param {import('$conversationTypes').MessageData?} data */ function sendChatMessage(msgText, data = null) { isSendingMsg = true; @@ -432,7 +432,7 @@ clearInstantLogs(); renewUserSentMessages(msgText); const postback = buildPostbackMessage(dialogs, data?.payload || msgText, data?.truncateMsgId); - /** @type {import('$types').MessageData?} */ + /** @type {import('$conversationTypes').MessageData?} */ let messageData = { ...data, postback: postback @@ -611,12 +611,12 @@ } /** - * @param {import('$types').ChatResponseModel[]} dialogs + * @param {import('$conversationTypes').ChatResponseModel[]} dialogs * @param {string?} content * @param {string?} [truncateMsgId] */ function buildPostbackMessage(dialogs, content, truncateMsgId) { - /** @type {import('$types').Postback?} */ + /** @type {import('$conversationTypes').Postback?} */ let postback = null; let lastMsg = dialogs.slice(-1)[0]; @@ -768,7 +768,7 @@ /** * @param {any} e - * @param {import('$types').ChatResponseModel} message + * @param {import('$conversationTypes').ChatResponseModel} message */ function resendMessage(e, message) { e.preventDefault(); @@ -823,7 +823,7 @@ /** * @param {any} e - * @param {import('$types').ChatResponseModel} message + * @param {import('$conversationTypes').ChatResponseModel} message */ function editMessage(e, message) { e.preventDefault(); diff --git a/src/routes/chat/[agentId]/[conversationId]/instant-log/instant-log.svelte b/src/routes/chat/[agentId]/[conversationId]/instant-log/instant-log.svelte index f53db05d..bcd209d6 100644 --- a/src/routes/chat/[agentId]/[conversationId]/instant-log/instant-log.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/instant-log/instant-log.svelte @@ -17,7 +17,7 @@ /** @type {any[]} */ export let agentQueueLogs = []; - /** @type {import('$types').ConversationStateLogModel?} */ + /** @type {import('$conversationTypes').ConversationStateLogModel?} */ export let latestStateLog = null; /** @type {() => void} */ diff --git a/src/routes/chat/[agentId]/[conversationId]/instant-log/latest-state-log.svelte b/src/routes/chat/[agentId]/[conversationId]/instant-log/latest-state-log.svelte index 7cdcbcf6..03a472e0 100644 --- a/src/routes/chat/[agentId]/[conversationId]/instant-log/latest-state-log.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/instant-log/latest-state-log.svelte @@ -1,7 +1,7 @@ diff --git a/src/routes/chat/[agentId]/[conversationId]/persist-log/content-log-element.svelte b/src/routes/chat/[agentId]/[conversationId]/persist-log/content-log-element.svelte index e74c59ae..c70cf983 100644 --- a/src/routes/chat/[agentId]/[conversationId]/persist-log/content-log-element.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/persist-log/content-log-element.svelte @@ -6,7 +6,7 @@ import { utcToLocal } from '$lib/helpers/datetime'; import { directToAgentPage } from '$lib/helpers/utils/common'; - /** @type {import('$types').ConversationContentLogModel} */ + /** @type {import('$conversationTypes').ConversationContentLogModel} */ export let data; let logDisplayStyle = ''; diff --git a/src/routes/chat/[agentId]/[conversationId]/persist-log/persist-log.svelte b/src/routes/chat/[agentId]/[conversationId]/persist-log/persist-log.svelte index dded9700..ddf84081 100644 --- a/src/routes/chat/[agentId]/[conversationId]/persist-log/persist-log.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/persist-log/persist-log.svelte @@ -12,13 +12,13 @@ const contentLogTab = 1; const conversationStateLogTab = 2; - /** @type {import('$types').ConversationContentLogModel[]} */ + /** @type {import('$conversationTypes').ConversationContentLogModel[]} */ export let contentLogs = []; - /** @type {import('$types').ConversationStateLogModel[]} */ + /** @type {import('$conversationTypes').ConversationStateLogModel[]} */ export let convStateLogs = []; - /** @type {import('$types').ConversationStateLogModel?} */ + /** @type {import('$conversationTypes').ConversationStateLogModel?} */ export let lastestStateLog = null; /** @type {boolean} */ diff --git a/src/routes/chat/[agentId]/[conversationId]/rich-content/rich-content.svelte b/src/routes/chat/[agentId]/[conversationId]/rich-content/rich-content.svelte index 618b1761..3786ecf6 100644 --- a/src/routes/chat/[agentId]/[conversationId]/rich-content/rich-content.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/rich-content/rich-content.svelte @@ -4,7 +4,7 @@ import RcComplexOptions from "./rc-complex-options.svelte"; import ChatAttachmentOptions from "../chat-util/chat-attachment-options.svelte"; - /** @type {import('$types').ChatResponseModel?} */ + /** @type {import('$conversationTypes').ChatResponseModel?} */ export let message; /** @type {boolean} */ diff --git a/src/routes/page/conversation/+page.svelte b/src/routes/page/conversation/+page.svelte index 6fcc02f1..1fb4139a 100644 --- a/src/routes/page/conversation/+page.svelte +++ b/src/routes/page/conversation/+page.svelte @@ -35,15 +35,15 @@ const firstPage = 1; const pageSize = 10; - /** @type {import('$commonTypes').PagedItems} */ + /** @type {import('$commonTypes').PagedItems} */ let conversations = { count: 0, items: [] }; - /** @type {import('$types').ConversationFilter} */ + /** @type {import('$conversationTypes').ConversationFilter} */ const initFilter = { pager: { page: firstPage, size: pageSize, count: 0 } }; - /** @type {import('$types').ConversationFilter} */ + /** @type {import('$conversationTypes').ConversationFilter} */ let filter = { ... initFilter }; /** @type {import('$commonTypes').Pagination} */ @@ -56,7 +56,7 @@ let agentOptions = []; /** - * @type {{agentId: string?, channel: string?, status: string?, taskId: string?, states: import('$types').UserStateDetailModel[]}} + * @type {{agentId: string?, channel: string?, status: string?, taskId: string?, states: import('$conversationTypes').UserStateDetailModel[]}} * */ let searchOption = { agentId: null, diff --git a/src/routes/page/conversation/[conversationId]/+page.svelte b/src/routes/page/conversation/[conversationId]/+page.svelte index 68cb9792..c28f2add 100644 --- a/src/routes/page/conversation/[conversationId]/+page.svelte +++ b/src/routes/page/conversation/[conversationId]/+page.svelte @@ -13,7 +13,7 @@ const params = $page.params; - /** @type {import('$types').ConversationModel} */ + /** @type {import('$conversationTypes').ConversationModel} */ let conversation; onMount(async () => { diff --git a/src/routes/page/conversation/[conversationId]/conv-dialog-element.svelte b/src/routes/page/conversation/[conversationId]/conv-dialog-element.svelte index da157e2d..6591844f 100644 --- a/src/routes/page/conversation/[conversationId]/conv-dialog-element.svelte +++ b/src/routes/page/conversation/[conversationId]/conv-dialog-element.svelte @@ -2,7 +2,7 @@ import Markdown from '$lib/common/Markdown.svelte'; import { Button } from '@sveltestrap/sveltestrap'; - /** @type {import('$types').ChatResponseModel} */ + /** @type {import('$conversationTypes').ChatResponseModel} */ export let dialog; let is_collapsed = true; diff --git a/src/routes/page/conversation/[conversationId]/conv-dialogs.svelte b/src/routes/page/conversation/[conversationId]/conv-dialogs.svelte index 5145cdb3..25c0b2d2 100644 --- a/src/routes/page/conversation/[conversationId]/conv-dialogs.svelte +++ b/src/routes/page/conversation/[conversationId]/conv-dialogs.svelte @@ -10,10 +10,10 @@ import { FileSourceType } from '$lib/helpers/enums'; import ConvDialogElement from './conv-dialog-element.svelte'; - /** @type {import('$types').ChatResponseModel[]} */ + /** @type {import('$conversationTypes').ChatResponseModel[]} */ let dialogs = []; - /** @type {import('$types').ConversationModel} */ + /** @type {import('$conversationTypes').ConversationModel} */ export let conversation; onMount(async () => { @@ -21,7 +21,7 @@ }); /** - * @param {import('$types').ChatResponseModel} dialog + * @param {import('$conversationTypes').ChatResponseModel} dialog * @returns {boolean} */ function showInRight(dialog) { diff --git a/src/routes/page/conversation/[conversationId]/conv-overview.svelte b/src/routes/page/conversation/[conversationId]/conv-overview.svelte index 2294efec..98b96da7 100644 --- a/src/routes/page/conversation/[conversationId]/conv-overview.svelte +++ b/src/routes/page/conversation/[conversationId]/conv-overview.svelte @@ -3,7 +3,7 @@ import { format } from '$lib/helpers/datetime'; import { _ } from 'svelte-i18n' - /** @type {import('$types').ConversationModel} */ + /** @type {import('$conversationTypes').ConversationModel} */ export let conversation; diff --git a/src/routes/page/conversation/[conversationId]/conv-states.svelte b/src/routes/page/conversation/[conversationId]/conv-states.svelte index 7078fac5..3706324a 100644 --- a/src/routes/page/conversation/[conversationId]/conv-states.svelte +++ b/src/routes/page/conversation/[conversationId]/conv-states.svelte @@ -3,7 +3,7 @@ import jsonview from '@pgrabovets/json-view'; import { onMount } from 'svelte'; - /** @type {import('$types').ConversationModel} */ + /** @type {import('$conversationTypes').ConversationModel} */ export let conversation; onMount(() => { diff --git a/src/routes/page/task/[taskId]/execution-flow.svelte b/src/routes/page/task/[taskId]/execution-flow.svelte index 334b34ea..50a95286 100644 --- a/src/routes/page/task/[taskId]/execution-flow.svelte +++ b/src/routes/page/task/[taskId]/execution-flow.svelte @@ -94,7 +94,7 @@ editor.zoom_reset(); } - /** @param {import('$types').ConversationModel} conversation */ + /** @param {import('$conversationTypes').ConversationModel} conversation */ function renderConversationNode(conversation) { let posX = lastPosX + 250 + nodeSpaceX, posY = lastPosY; let html = "New conversation"; @@ -109,7 +109,7 @@ /** * @param {string} message - * @param {import('$types').ChatResponseModel} response + * @param {import('$conversationTypes').ChatResponseModel} response * @param {boolean} isSuccess */ function renderMessageNode(message, response, isSuccess) { diff --git a/svelte.config.js b/svelte.config.js index f446b5e7..4b883d37 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -7,14 +7,13 @@ const config = { // preprocess: vitePreprocess(), kit: { alias: { - $types: './src/lib/helpers/types/types.js', + $commonTypes: './src/lib/helpers/types/commonTypes.js', $agentTypes: './src/lib/helpers/types/agentTypes.js', $conversationTypes: './src/lib/helpers/types/conversationTypes.js', $knowledgeTypes: './src/lib/helpers/types/knowledgeTypes.js', $fileTypes: './src/lib/helpers/types/fileTypes.js', $audioTypes: './src/lib/helpers/types/audioTypes.js', $userTypes: './src/lib/helpers/types/userTypes.js', - $commonTypes: './src/lib/helpers/types/commonTypes.js', $pluginTypes: './src/lib/helpers/types/pluginTypes.js', }, From 7b00ee56a977ccd67a4f5dd59720f10490ad8334 Mon Sep 17 00:00:00 2001 From: Jicheng Lu Date: Wed, 4 Sep 2024 19:26:48 -0500 Subject: [PATCH 5/5] collapse function call --- .../[conversationId]/persist-log/content-log-element.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/routes/chat/[agentId]/[conversationId]/persist-log/content-log-element.svelte b/src/routes/chat/[agentId]/[conversationId]/persist-log/content-log-element.svelte index c70cf983..0e536e77 100644 --- a/src/routes/chat/[agentId]/[conversationId]/persist-log/content-log-element.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/persist-log/content-log-element.svelte @@ -15,7 +15,8 @@ const unknownAgent = "Uknown"; const includedSources = [ ContentLogSource.Prompt, - ContentLogSource.AgentResponse + ContentLogSource.AgentResponse, + ContentLogSource.FunctionCall ]; $: {