From 22f588ccf3fa74adddefdac0088643c0f9bd5222 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Wed, 4 Dec 2024 16:11:28 -0600 Subject: [PATCH] refine utility name --- src/lib/helpers/types/agentTypes.js | 1 + src/lib/helpers/utils/common.js | 17 +++++ .../[conversationId]/chat-box.svelte | 4 +- .../page/agent/[agentId]/agent-utility.svelte | 63 ++++++++++++++----- 4 files changed, 67 insertions(+), 18 deletions(-) diff --git a/src/lib/helpers/types/agentTypes.js b/src/lib/helpers/types/agentTypes.js index b68a9b0d..1059e53a 100644 --- a/src/lib/helpers/types/agentTypes.js +++ b/src/lib/helpers/types/agentTypes.js @@ -128,6 +128,7 @@ /** * @typedef {Object} UtilityBase * @property {string} name + * @property {string?} [displayName] */ export default {}; \ No newline at end of file diff --git a/src/lib/helpers/utils/common.js b/src/lib/helpers/utils/common.js index 84b5d2ef..d3ae5566 100644 --- a/src/lib/helpers/utils/common.js +++ b/src/lib/helpers/utils/common.js @@ -50,4 +50,21 @@ export function formatObject(object) { } catch { return object; } +} + + +/** + * @param {string?} str + * @param {string?} prefix + */ +export function truncateByPrefix(str, prefix) { + if (!str || !prefix) { + return str; + } + + if (!str.startsWith(prefix)) { + return str; + } + + return str.replace(prefix, ''); } \ 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 8220910d..94378811 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -1759,7 +1759,7 @@ {#if !!lastBotMsg && !isSendingMsg && !isThinking} confirmSelectedOption(title, payload)} /> {/if} @@ -1843,7 +1843,7 @@