diff --git a/src/lib/helpers/http.js b/src/lib/helpers/http.js index e82610d6..0a6c09a0 100644 --- a/src/lib/helpers/http.js +++ b/src/lib/helpers/http.js @@ -108,7 +108,9 @@ function skipLoader(config) { new RegExp('http(s*)://(.*?)/user/(.*?)/details', 'g'), new RegExp('http(s*)://(.*?)/agent/labels', 'g'), new RegExp('http(s*)://(.*?)/conversation/state/keys', 'g'), - new RegExp('http(s*)://(.*?)/logger/instruction/log/keys', 'g') + new RegExp('http(s*)://(.*?)/logger/instruction/log/keys', 'g'), + new RegExp('http(s*)://(.*?)/logger/conversation/(.*?)/content-log', 'g'), + new RegExp('http(s*)://(.*?)/logger/conversation/(.*?)/state-log', 'g') ]; if (config.method === 'post' && postRegexes.some(regex => regex.test(config.url || ''))) { diff --git a/src/lib/helpers/types/commonTypes.js b/src/lib/helpers/types/commonTypes.js index 10a1188b..e4125825 100644 --- a/src/lib/helpers/types/commonTypes.js +++ b/src/lib/helpers/types/commonTypes.js @@ -24,6 +24,14 @@ * @property {T[]} items - Items. */ +/** + * @template T + * @typedef {Object} DateTimePagedItems + * @property {number} count - Row count. + * @property {T[]} items - Items. + * @property {Date?} [nextTime] + */ + /** * @typedef {Object} LlmConfigOption * @property {number?} [type] diff --git a/src/lib/helpers/types/conversationTypes.js b/src/lib/helpers/types/conversationTypes.js index 76e1ce10..41d94a75 100644 --- a/src/lib/helpers/types/conversationTypes.js +++ b/src/lib/helpers/types/conversationTypes.js @@ -152,6 +152,7 @@ IRichContent.prototype.quick_replies; /** * @typedef {Object} ConversationContentLogModel + * @property {string?} [uid] * @property {string} conversation_id - The conversation id. * @property {string} message_id - The message id. * @property {string} name - The sender name. @@ -164,12 +165,19 @@ IRichContent.prototype.quick_replies; /** * @typedef {Object} ConversationStateLogModel + * @property {string?} [uid] * @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} ConversationLogFilter + * @property {number} size + * @property {Date?} [startTime] + */ + /** * @typedef {Object} MessageStateLogModel * @property {string} conversation_id - The conversation id. diff --git a/src/lib/scss/custom/pages/_chat.scss b/src/lib/scss/custom/pages/_chat.scss index 3270c7a0..f5b62fa3 100644 --- a/src/lib/scss/custom/pages/_chat.scss +++ b/src/lib/scss/custom/pages/_chat.scss @@ -86,7 +86,7 @@ .chat-head-info { display: flex; - flex: 0 0 fit-content; + // flex: 0 0 fit-content; flex-direction: column; height: 100%; gap: 5px; diff --git a/src/lib/services/conversation-service.js b/src/lib/services/conversation-service.js index 0871adf3..4ea614a1 100644 --- a/src/lib/services/conversation-service.js +++ b/src/lib/services/conversation-service.js @@ -80,11 +80,16 @@ export async function deleteConversation(conversationId) { /** * Get dialog history * @param {string} conversationId + * @param {number} count * @returns {Promise} */ -export async function getDialogs(conversationId) { +export async function getDialogs(conversationId, count = 100) { let url = replaceUrl(endpoints.dialogsUrl, {conversationId: conversationId}); - const response = await axios.get(url); + const response = await axios.get(url, { + params: { + count: count + } + }); return response.data; } diff --git a/src/lib/services/logging-service.js b/src/lib/services/logging-service.js index bed88b62..9d272f75 100644 --- a/src/lib/services/logging-service.js +++ b/src/lib/services/logging-service.js @@ -23,22 +23,32 @@ export async function getFullLog() { /** * Get conversation content log - * @param {string} conversationId - * @returns {Promise} + * @param {string} conversationId + * @param {import('$conversationTypes').ConversationLogFilter} filter + * @returns {Promise>} */ -export async function GetContentLogs(conversationId) { +export async function getContentLogs(conversationId, filter) { let url = replaceUrl(endpoints.loggingContentLogUrl, {conversationId: conversationId}); - const response = await axios.get(url); + const response = await axios.get(url, { + params: { + ...filter + } + }); return response.data; } /** * Get conversation state log - * @param {string} conversationId - * @returns {Promise} + * @param {string} conversationId + * @param {import('$conversationTypes').ConversationLogFilter} filter + * @returns {Promise>} */ -export async function GetStateLogs(conversationId) { +export async function getStateLogs(conversationId, filter) { let url = replaceUrl(endpoints.loggingStateLogUrl, {conversationId: conversationId}); - const response = await axios.get(url); + const response = await axios.get(url, { + params: { + ...filter + } + }); return response.data; } \ No newline at end of file diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index 7bcce772..14da5a4d 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -88,9 +88,10 @@ const params = $page.params; const messageLimit = 100; const screenWidthThreshold = 1024; - const chatWidthThreshold = 300; + const chatWidthThreshold = 500; const maxTextLength = 64000; const duration = 2000; + const dialogCount = 50; const MESSAGE_STORAGE_KEY = 'message_draft_'; /** @type {import('$agentTypes').AgentModel} */ @@ -219,7 +220,7 @@ onMount(async () => { disableSpeech = navigator.userAgent.includes('Firefox'); conversation = await getConversation(params.conversationId); - dialogs = await getDialogs(params.conversationId); + dialogs = await getDialogs(params.conversationId, dialogCount); conversationUser = await getConversationUser(params.conversationId); selectedTags = conversation?.tags || []; initUserSentMessages(dialogs); @@ -494,7 +495,8 @@ /** @param {import('$conversationTypes').ConversationContentLogModel} log */ function onConversationContentLogGenerated(log) { if (!isLoadPersistLog) return; - contentLogs.push({ ...log }); + + contentLogs.push({ ...log, uid: uuidv4() }); contentLogs = contentLogs.map(x => { return { ...x }; }); } @@ -503,7 +505,7 @@ if (!isLoadPersistLog) return; latestStateLog = log; - convStateLogs.push({ ...log }); + convStateLogs.push({ ...log, uid: uuidv4() }); convStateLogs = convStateLogs.map(x => { return { ...x }; }); } @@ -1489,7 +1491,7 @@
-
+
{#if agent?.icon_url}
@@ -1507,9 +1509,9 @@
- -
-
+ +
+
{#if PUBLIC_DEBUG_MODE === 'true' && isFrame}
+
{#if data.message_id} -
- {`MessageId: ${data.message_id}`} -
+
+ {`MessageId: ${data.message_id}`} +
{/if}
\ No newline at end of file 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 5ecc9ddc..c22659f5 100644 --- a/src/routes/chat/[agentId]/[conversationId]/persist-log/persist-log.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/persist-log/persist-log.svelte @@ -1,16 +1,31 @@