Skip to content

Commit 2e2a5c2

Browse files
committed
2 parents b31f588 + 34e0155 commit 2e2a5c2

File tree

13 files changed

+88
-32
lines changed

13 files changed

+88
-32
lines changed

src/lib/common/errors/error-500.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</h1>
1919
<h4 class="text-uppercase">Internal Server Error</h4>
2020
<div class="mt-5 text-center">
21-
<Link class="btn btn-primary" href="/dashboard">
21+
<Link class="btn btn-primary" href="page/dashboard">
2222
Back to Dashboard
2323
</Link>
2424
</div>

src/lib/helpers/enums.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
const userRole = {
22
System: "system",
3+
Admin: "admin",
34
User: "user",
45
Client: "client",
56
Function: "function",
67
Assistant: "assistant"
78
};
8-
99
export const UserRole = Object.freeze(userRole);
1010

1111
const senderAction = {
1212
TypingOn: 1,
1313
TypingOff: 2,
1414
MarkSeen: 3
1515
}
16-
1716
export const SenderAction = Object.freeze(senderAction);
1817

1918
const richType = {
@@ -22,5 +21,13 @@ const richType = {
2221
Button: 'button_template',
2322
MultiSelect: 'multi-select_template'
2423
}
24+
export const RichType = Object.freeze(richType);
2525

26-
export const RichType = Object.freeze(richType);
26+
const contentLogSource = {
27+
UserInput: "user input",
28+
Prompt: "prompt",
29+
FunctionCall: "function call",
30+
AgentResponse: "agent response",
31+
HardRule: "hard rule"
32+
};
33+
export const ContentLogSource = Object.freeze(contentLogSource);

src/lib/helpers/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ IRichContent.prototype.text;
264264
* @property {string} conversation_id - The conversation id.
265265
* @property {string} name - The sender name.
266266
* @property {string} role - The sender role.
267+
* @property {string} source - The log source.
267268
* @property {string} content - The log content.
268269
* @property {Date} created_at - The log sent time.
269270
*/

src/lib/scss/custom/pages/_chat.scss

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277

278278
.chat-input-section {
279279
border-top: 1px solid var(--#{$prefix}border-color);
280+
padding: 2vmin 2% 2vmin 2%;
280281
}
281282

282283
.chat-input {
@@ -311,8 +312,13 @@
311312
height: 100vh;
312313

313314
.padding-side {
314-
padding-left: 10px;
315+
padding-left: 20px;
315316
padding-right: 20px;
317+
318+
ul {
319+
padding-left: 2px !important;
320+
padding-right: 0px !important;
321+
}
316322
}
317323

318324
.log-background {
@@ -323,7 +329,8 @@
323329
margin-bottom: 10px;
324330
position: sticky;
325331
display: flex;
326-
justify-content: flex-end;
332+
// justify-content: flex-end;
333+
justify-content: space-between;
327334
}
328335

329336
.log-list {

src/routes/(authentication)/recoverpw/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</div>
2828
<CardBody class="pt-0">
2929
<div>
30-
<Link href="/dashboard">
30+
<Link href="page/dashboard">
3131
<div class="avatar-md profile-user-wid mb-4">
3232
<span class="avatar-title rounded-circle bg-light">
3333
<img src={PUBLIC_LOGO_URL} alt="" class="rounded-circle" height="34" />
@@ -41,7 +41,7 @@
4141
Enter your Email and instructions will be sent to you!
4242
</Alert>
4343

44-
<Form class="form-horizontal" action="/dashboard">
44+
<Form class="form-horizontal" action="page/dashboard">
4545
<div class="mb-3">
4646
<Label for="useremail" class="form-label">Email</Label>
4747
<Input

src/routes/(authentication)/register/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
</div>
7777
<CardBody class="pt-0">
7878
<div>
79-
<Link href="/dashboard">
79+
<Link href="page/dashboard">
8080
<div class="avatar-md profile-user-wid mb-4">
8181
<span class="avatar-title rounded-circle bg-light">
8282
<img src={PUBLIC_LOGO_URL} alt="" class="rounded-circle" height="34" />

src/routes/VerticalLayout/Header.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<div class="d-flex">
5050
<!-- LOGO -->
5151
<div class="navbar-brand-box">
52-
<a href="/dashboard" class="logo logo-dark">
52+
<a href="page/dashboard" class="logo logo-dark">
5353
<span class="logo-sm">
5454
<img src={PUBLIC_LOGO_URL} alt="" height="25" />
5555
</span>
@@ -58,7 +58,7 @@
5858
</span>
5959
</a>
6060

61-
<a href="/dashboard" class="logo logo-light">
61+
<a href="page/dashboard" class="logo logo-light">
6262
<span class="logo-sm">
6363
<img src={PUBLIC_LOGO_URL} alt="" height="25" />
6464
</span>

src/routes/chat/[agentId]/[conversationId]/chat-box.svelte

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,21 @@
332332
}
333333
}
334334
335+
function cleanContentLogScreen() {
336+
contentLogs = [];
337+
}
338+
335339
function toggleStateLog() {
336340
isLoadStateLog = !isLoadStateLog;
337341
if (!isLoadStateLog) {
338342
stateLogs = [];
339343
}
340344
}
341345
346+
function cleanStateLogScreen() {
347+
stateLogs = [];
348+
}
349+
342350
function toggleAddStateModal() {
343351
isOpenAddStateModal = !isOpenAddStateModal;
344352
}
@@ -427,8 +435,15 @@
427435
async function confirmEditMsg() {
428436
const isDeleted = truncateDialogs(truncateMsgId);
429437
if (!isDeleted) return;
430-
toggleEditMsgModal();
431-
await sendMessageToHub(params.agentId, params.conversationId, editText, truncateMsgId);
438+
439+
isSendingMsg = true;
440+
sendMessageToHub(params.agentId, params.conversationId, editText, truncateMsgId).then(() => {
441+
isSendingMsg = false;
442+
toggleEditMsgModal();
443+
}).catch(() => {
444+
isSendingMsg = false;
445+
toggleEditMsgModal();
446+
});
432447
}
433448
434449
/** @param {string} messageId */
@@ -467,7 +482,7 @@
467482
<Splitpanes>
468483
{#if isLoadStateLog}
469484
<Pane size={30} minSize={20} maxSize={50} >
470-
<StateLog stateLogs={stateLogs} closeWindow={toggleStateLog} />
485+
<StateLog stateLogs={stateLogs} closeWindow={toggleStateLog} cleanScreen={cleanStateLogScreen} />
471486
</Pane>
472487
{/if}
473488
<Pane minSize={20}>
@@ -630,7 +645,7 @@
630645
</div>
631646
</div>
632647
633-
<div class="chat-input-section" style="height: 8%; padding: 2%">
648+
<div class="chat-input-section" style="height: 8%;">
634649
<div class="row">
635650
<div class="col-auto">
636651
<button
@@ -669,7 +684,7 @@
669684
</Pane>
670685
{#if isLoadContentLog}
671686
<Pane size={30} minSize={20} maxSize={50}>
672-
<ContentLog contentLogs={contentLogs} closeWindow={toggleContentLog} />
687+
<ContentLog contentLogs={contentLogs} closeWindow={toggleContentLog} cleanScreen={cleanContentLogScreen} />
673688
</Pane>
674689
{/if}
675690
</Splitpanes>

src/routes/chat/[agentId]/[conversationId]/contentLogs/content-log-element.svelte

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22
import { Button } from '@sveltestrap/sveltestrap';
33
import moment from 'moment';
44
import { replaceNewLine } from '$lib/helpers/http';
5-
import { UserRole } from '$lib/helpers/enums';
5+
import { ContentLogSource } from '$lib/helpers/enums';
66
77
/** @type {import('$types').ConversationContentLogModel} */
88
export let data;
99
1010
let logBackground = '';
1111
let is_collapsed = true;
12-
const excludedRoles = [
13-
UserRole.User,
14-
UserRole.Assistant
12+
const includedSources = [
13+
ContentLogSource.Prompt
1514
];
1615
1716
$: {
18-
if (data.role == UserRole.Assistant) {
17+
if (data.source === ContentLogSource.AgentResponse) {
1918
logBackground = 'bg-info';
20-
} else if (data.role == UserRole.Function) {
19+
} else if (data.source === ContentLogSource.FunctionCall) {
2120
logBackground = 'bg-secondary';
21+
} else if (data.source === ContentLogSource.Prompt) {
22+
logBackground = 'bg-danger';
23+
} else if (data.source === ContentLogSource.HardRule) {
24+
logBackground = "bg-warning";
2225
}
2326
}
2427
@@ -34,10 +37,10 @@
3437
<b>{`[${data?.name?.length > 0 ? data?.name + ' ' : ''}${moment.utc(data?.created_at).local().format('hh:mm:ss.SSS A, MMM DD YYYY')}]`}</b>
3538
</div>
3639
<br>
37-
<div class="log-content" class:log-collapse={!excludedRoles.includes(data.role) && !!is_collapsed}>
40+
<div class="log-content" class:log-collapse={includedSources.includes(data.source) && !!is_collapsed}>
3841
{@html replaceNewLine(data?.content)}
3942
</div>
40-
{#if !excludedRoles.includes(data.role)}
43+
{#if includedSources.includes(data.source)}
4144
<Button class='toggle-btn' color="link" on:click={(e) => toggleText(e)}>
4245
{`${is_collapsed ? 'More +' : 'Less -'}`}
4346
</Button>

src/routes/chat/[agentId]/[conversationId]/contentLogs/content-log.svelte

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
/** @type {() => void} */
1313
export let closeWindow;
1414
15+
/** @type {() => void} */
16+
export let cleanScreen;
17+
1518
// @ts-ignore
1619
let scrollbar;
1720
/** @type {import('$types').ConversationContentLogModel[]} */
@@ -63,12 +66,20 @@
6366

6467
<div class="chat-log">
6568
<div class="card mb-0 log-background" style="height: 100%;">
66-
<div class="log-close-btn padding-side ">
69+
<div class="log-close-btn padding-side">
70+
<button
71+
type="button"
72+
class="btn btn-sm btn-secondary btn-rounded chat-send waves-effect waves-light"
73+
on:click={() => cleanScreen()}
74+
>
75+
<i class="bx bx-trash"></i>
76+
</button>
6777
<button
6878
type="button"
6979
class="btn btn-sm btn-secondary btn-rounded chat-send waves-effect waves-light"
7080
on:click={() => closeWindow()}
71-
><i class="mdi mdi-window-close"></i>
81+
>
82+
<i class="mdi mdi-window-close"></i>
7283
</button>
7384
</div>
7485
<div class="content-log-scrollbar log-list padding-side">

0 commit comments

Comments
 (0)