Skip to content

Commit 50fc013

Browse files
author
roary.yao
committed
Merge branch 'main' of https://github.com/SciSharp/BotSharp-UI into roary-features/chat-window
2 parents be9d637 + 28ff75c commit 50fc013

File tree

9 files changed

+108
-40
lines changed

9 files changed

+108
-40
lines changed

src/lib/helpers/types/agentTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* @property {string?} provider
1616
* @property {string?} model
1717
* @property {number} max_recursion_depth
18+
* @property {number?} [max_output_tokens]
1819
*/
1920

2021

src/lib/scss/custom/pages/_agent.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@
217217
}
218218
}
219219

220+
.agent-card-header {
221+
display: flex;
222+
gap: 10px;
223+
flex-wrap: wrap;
224+
}
225+
220226
.agent-label-container {
221227
display: flex;
222228
gap: 5px;

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,18 @@
102102
height: 80%;
103103
max-height: 25px;
104104
}
105+
106+
.chat-head-agent-name {
107+
font-size: 0.8em;
108+
}
105109
}
106110

107111
.chat-head-user {
108112
flex: 0.5;
109113
display: flex;
110114
gap: 5px;
111115
width: fit-content;
112-
font-size: 12px;
116+
font-size: 0.7em !important;
113117
}
114118
}
115119
}
@@ -127,6 +131,7 @@
127131
display: flex;
128132
justify-content: flex-end;
129133
align-items: center;
134+
gap: 5px;
130135
}
131136

132137
.user-chat-nav {
@@ -141,8 +146,14 @@
141146
background-color: var(--#{$prefix}light);
142147
border-radius: 50%;
143148
border: none;
144-
width: 40px;
145-
height: 40px;
149+
// width: 40px;
150+
// height: 40px;
151+
width: 2em;
152+
height: 2em;
153+
154+
i {
155+
font-size: 0.8em;
156+
}
146157
}
147158

148159
.dropdown {
@@ -176,6 +187,10 @@
176187
border-top-left-radius: 0px;
177188
border-bottom-left-radius: 0px;
178189
}
190+
191+
i, span {
192+
font-size: 0.9em;
193+
}
179194
}
180195
}
181196

@@ -420,6 +435,10 @@
420435

421436
.log-footer {
422437
flex: 2%;
438+
439+
.log-footer-nav-btn {
440+
font-size: 0.75em;
441+
}
423442
}
424443

425444
.instant-log-body {

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

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
const params = $page.params;
8989
const messageLimit = 100;
9090
const screenWidthThreshold = 1024;
91+
const chatWidthThreshold = 300;
9192
const maxTextLength = 64000;
9293
const duration = 2000;
9394
@@ -226,6 +227,7 @@
226227
if (messageDraft) {
227228
text = messageDraft;
228229
}
230+
handlePaneResize();
229231
230232
signalr.onMessageReceivedFromClient = onMessageReceivedFromClient;
231233
signalr.onMessageReceivedFromCsr = onMessageReceivedFromClient;
@@ -669,7 +671,7 @@
669671
if (disableSpeech) return;
670672
671673
if (!isListening) {
672-
llmRealtime.start(params.agentId, message => {
674+
llmRealtime.start(params.agentId, (/** @type {any} */ message) => {
673675
console.log(message);
674676
});
675677
isListening = true;
@@ -1351,6 +1353,13 @@
13511353
function deleteMessageDraft() {
13521354
messageStorage.remove(MESSAGE_STORAGE_KEY + params.conversationId);
13531355
}
1356+
function handlePaneResize() {
1357+
const header = document.querySelector('.chat-head');
1358+
if (!header) return;
1359+
1360+
const width = header.getBoundingClientRect().width;
1361+
isLite = width < chatWidthThreshold;
1362+
}
13541363
</script>
13551364
13561365
@@ -1466,9 +1475,9 @@
14661475
14671476
<HeadTitle title="Chat" addOn='' />
14681477
<div class="d-lg-flex">
1469-
<Splitpanes>
1478+
<Splitpanes on:resize={() => handlePaneResize()}>
14701479
{#if isLoadInstantLog}
1471-
<Pane size={30} minSize={20} maxSize={50} >
1480+
<Pane size={30} minSize={25} maxSize={40} >
14721481
<InstantLog
14731482
bind:msgStateLogs={msgStateLogs}
14741483
bind:agentQueueLogs={agentQueueLogs}
@@ -1478,7 +1487,7 @@
14781487
/>
14791488
</Pane>
14801489
{/if}
1481-
<Pane minSize={20}>
1490+
<Pane minSize={30}>
14821491
<div style="height: 100vh;">
14831492
<div class="card mb-0" style="height: 100vh;">
14841493
<div class="border-bottom chat-head">
@@ -1503,18 +1512,18 @@
15031512
</div>
15041513
15051514
<div class="col-md-8 col-5">
1506-
<ul class="list-inline user-chat-nav user-chat-nav-flex mb-0">
1515+
<div class="user-chat-nav user-chat-nav-flex mb-0">
15071516
{#if PUBLIC_DEBUG_MODE === 'true' && isFrame}
1508-
<li class="list-inline-item">
1517+
<div class="">
15091518
<button
15101519
class="btn btn-secondary btn-rounded btn-sm"
15111520
on:click={() => openFullScreen()}
15121521
>
15131522
<i class="bx bx-fullscreen" />
15141523
</button>
1515-
</li>
1524+
</div>
15161525
{/if}
1517-
<li class="list-inline-item">
1526+
<div class="">
15181527
{#if !isLite}
15191528
<Dropdown>
15201529
<DropdownToggle class="nav-btn dropdown-toggle">
@@ -1581,9 +1590,9 @@
15811590
/>
15821591
</button>
15831592
{/if}
1584-
</li>
1593+
</div>
15851594
1586-
<li class="list-inline-item btn-pair">
1595+
<div class="btn-pair">
15871596
{#if !isLite}
15881597
<button
15891598
class={`btn btn-rounded btn-sm btn-primary btn-left`}
@@ -1592,13 +1601,12 @@
15921601
>
15931602
<span
15941603
data-bs-toggle="tooltip"
1595-
data-bs-placement="top"
1604+
data-bs-placement="bottom"
15961605
title="New Conversation"
15971606
>
15981607
<i class="mdi mdi-plus" />
15991608
<span class="me-2">New</span>
16001609
</span>
1601-
16021610
</button>
16031611
{/if}
16041612
<button
@@ -1611,8 +1619,8 @@
16111619
{/if}
16121620
<i class="mdi mdi-window-close" />
16131621
</button>
1614-
</li>
1615-
</ul>
1622+
</div>
1623+
</div>
16161624
</div>
16171625
</div>
16181626
</div>
@@ -1901,7 +1909,7 @@
19011909
</div>
19021910
</Pane>
19031911
{#if isLoadPersistLog}
1904-
<Pane size={30} minSize={20} maxSize={50}>
1912+
<Pane size={30} minSize={25} maxSize={40}>
19051913
<PersistLog
19061914
bind:contentLogs={contentLogs}
19071915
bind:convStateLogs={convStateLogs}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
<NavBar id={'persist-log-container'}>
160160
<NavItem
161161
navBtnId={'content-log-tab'}
162+
navBtnClasses={'log-footer-nav-btn'}
162163
dataBsTarget={'#content-log-tab-pane'}
163164
ariaControls={'content-log-tab-pane'}
164165
navBtnText={'Content Log'}
@@ -168,6 +169,7 @@
168169
/>
169170
<NavItem
170171
navBtnId={'conv-state-log-tab'}
172+
navBtnClasses={'log-footer-nav-btn'}
171173
dataBsTarget={'#conv-state-log-tab-pane'}
172174
ariaControls={'conv-state-log-tab-pane'}
173175
navBtnText={'Conversation States'}

src/routes/page/agent/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
filter = {
6767
pager: initFilter.pager,
6868
types: selectedAgentTypes?.length > 0 ? selectedAgentTypes : null,
69+
labels: selectedAgentLabels?.length > 0 ? selectedAgentLabels : null,
6970
similarName: event.payload || null
7071
};
7172
getPagedAgents();

src/routes/page/agent/[agentId]/+page.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@
102102
utilities: agent.utilities || [],
103103
knowledge_bases: agent.knowledge_bases || [],
104104
rules: agent.rules || [],
105-
max_message_count: Number(agent.max_message_count) > 0 ? Number(agent.max_message_count) : null
105+
max_message_count: Number(agent.max_message_count) > 0 ? Number(agent.max_message_count) : null,
106+
llm_config: {
107+
...agent.llm_config,
108+
max_output_tokens: Number(agent.llm_config.max_output_tokens) > 0 ? Number(agent.llm_config.max_output_tokens) : null
109+
}
106110
};
107111
isLoading = true;
108112
saveAgent(agent).then(res => {

src/routes/page/agent/[agentId]/agent-components/agent-llm-config.svelte

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
/** @type {() => void} */
1616
export let handleAgentChange;
1717
18-
const lowerLimit = 1;
19-
const upperLimit = 10;
18+
const recursiveDepthLowerLimit = 1;
19+
const recursiveDepthUpperLimit = 10;
2020
2121
let config = agent.llm_config;
2222
@@ -71,15 +71,21 @@
7171
function changeMaxRecursiveDepth(e) {
7272
let value = Number(e.target.value) || 0;
7373
74-
if (value < lowerLimit) {
75-
value = lowerLimit;
76-
} else if (value > upperLimit) {
77-
value = upperLimit;
74+
if (value < recursiveDepthLowerLimit) {
75+
value = recursiveDepthLowerLimit;
76+
} else if (value > recursiveDepthUpperLimit) {
77+
value = recursiveDepthUpperLimit;
7878
}
7979
8080
config.max_recursion_depth = value;
8181
handleAgentChange();
8282
}
83+
84+
/** @param {any} e */
85+
function changeMaxOutputToken(e) {
86+
const value = Number(e.target.value) || 0;
87+
config.max_output_tokens = value;
88+
}
8389
</script>
8490
8591
<Card>
@@ -126,11 +132,25 @@
126132
<Input
127133
style="text-align: center;"
128134
type="number"
129-
min={lowerLimit}
130-
max={upperLimit}
135+
min={recursiveDepthLowerLimit}
136+
max={recursiveDepthUpperLimit}
131137
value={config.max_recursion_depth}
132138
on:change={e => changeMaxRecursiveDepth(e)}
133-
/>
139+
/>
140+
</div>
141+
</div>
142+
143+
<div class="mb-3 row">
144+
<label for="example-text-input" class="col-md-3 col-form-label">
145+
Max output tokens
146+
</label>
147+
<div class="col-md-9">
148+
<Input
149+
style="text-align: center;"
150+
type="number"
151+
value={config.max_output_tokens}
152+
on:change={e => changeMaxOutputToken(e)}
153+
/>
134154
</div>
135155
</div>
136156
</CardBody>

src/routes/page/agent/card-agent.svelte

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,25 @@
2626
</div>
2727

2828
<div class="flex-grow-1 overflow-hidden">
29-
<h5 class="text-truncate font-size-15">
30-
<Link href= "page/agent/{agent.id}" class="text-dark">
31-
{agent.name}
32-
</Link>
33-
</h5>
29+
<div class="agent-card-header">
30+
<h5 class="text-truncate font-size-15 line-align-center mb-0">
31+
<Link href= "page/agent/{agent.id}" class="text-dark">
32+
{agent.name}
33+
</Link>
34+
</h5>
35+
{#if agent.is_router}
36+
<div
37+
class="font-size-15 line-align-center"
38+
data-bs-toggle="tooltip"
39+
data-bs-placement="bottom"
40+
title="Go to flowchart"
41+
>
42+
<Link href={`page/agent/router?agent_id=${agent.id}`} target="_blank">
43+
<i class="mdi mdi-sitemap" />
44+
</Link>
45+
</div>
46+
{/if}
47+
</div>
3448
{#if agent.labels?.length > 0}
3549
<div class="agent-label-container">
3650
{#each agent.labels as label}
@@ -75,13 +89,6 @@
7589
<i class="bx bx-calendar me-1" />
7690
{format(agent.updated_datetime, 'short-date')}
7791
</li>
78-
{#if agent.is_router}
79-
<li class="list-inline-item me-1 mt-1 mb-1">
80-
<Link href={`page/agent/router?agent_id=${agent.id}`} class="btn btn-primary btn-sm" target="_blank">
81-
<i class="mdi mdi-magnify" /> {$_('View')}
82-
</Link>
83-
</li>
84-
{/if}
8592
<li class="list-inline-item me-1 mt-1 mb-1">
8693
<Link href="page/agent/{agent.id}/build" class="btn btn-primary btn-sm" target="_blank" disabled>
8794
<i class="bx bx-wrench" /> {$_('Build')}

0 commit comments

Comments
 (0)