Skip to content

Commit ab44f8d

Browse files
authored
Merge pull request #142 from iceljc/features/refine-chat-window
add profile edit
2 parents 9e14168 + 24ad789 commit ab44f8d

File tree

4 files changed

+80
-8
lines changed

4 files changed

+80
-8
lines changed

src/lib/helpers/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
* @property {boolean} disabled
119119
* @property {boolean} is_public
120120
* @property {boolean} is_host
121+
* @property {boolean} is_router
122+
* @property {boolean} allow_routing
121123
* @property {string} icon_url - Icon
122124
* @property {string[]} profiles - The agent profiles.
123125
* @property {Date} created_datetime

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
}
44

55
.agent-profile-container {
6+
width: 50%;
67
.profile-name {
78
font-size: 1.1em;
89
}

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@
5858
function handleAgentUpdate() {
5959
fetchJsonContent();
6060
isLoading = true;
61-
agent.description = agent.description || '';
62-
agent.instruction = agent.instruction || '';
61+
agent = {
62+
...agent,
63+
description: agent.description || '',
64+
instruction: agent.instruction || '',
65+
profiles: agent.profiles?.filter(x => x?.trim()?.length > 0) || []
66+
};
6367
saveAgent(agent).then(res => {
6468
isLoading = false;
6569
isComplete = true;
@@ -119,7 +123,7 @@
119123
{#if agent}
120124
<Row>
121125
<Col style="flex: 30%;">
122-
<AgentOverview agent={agent} />
126+
<AgentOverview agent={agent} profiles={agent.profiles || []} />
123127
<AgentLlmConfig agent={agent} />
124128
{#if agent.routing_rules?.length > 0}
125129
<AgentRouting agent={agent} />
@@ -135,8 +139,8 @@
135139
{#if !!agent?.editable}
136140
<Row>
137141
<div class="hstack gap-2 my-4">
138-
<Button class="btn btn-soft-primary" on:click={updateCurrentAgent}>{$_('Save Agent')}</Button>
139-
<Button class="btn btn-danger" on:click={deleteCurrentAgent}>{$_('Delete Agent')}</Button>
142+
<Button class="btn btn-soft-primary" on:click={() => updateCurrentAgent()}>{$_('Save Agent')}</Button>
143+
<Button class="btn btn-danger" on:click={() => deleteCurrentAgent()}>{$_('Delete Agent')}</Button>
140144
</div>
141145
</Row>
142146
{/if}

src/routes/page/agent/[agentId]/agent-overview.svelte

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,48 @@
55
66
/** @type {import('$types').AgentModel} */
77
export let agent;
8+
9+
/** @type {string[]} */
10+
export let profiles = [];
11+
12+
const profileLimit = 5;
13+
14+
function addProfile() {
15+
if (!!!agent) return;
16+
17+
profiles = [...profiles, ''];
18+
agent.profiles = profiles;
19+
}
20+
21+
/**
22+
* @param {number} index
23+
*/
24+
function removeProfile(index) {
25+
profiles = profiles.filter((x, idx) => idx !== index);
26+
agent.profiles = profiles;
27+
}
28+
29+
function chatWithAgent() {
30+
if (!!!agent?.id) return;
31+
32+
window.open(`/chat/${agent?.id}`, '_blank');
33+
}
834
</script>
935
1036
<Card>
1137
<CardHeader>
1238
<div class="text-center">
13-
<img src="images/users/bot.png" alt="" height="50" class="mx-auto d-block" />
39+
<img
40+
src="images/users/bot.png"
41+
alt=""
42+
height="50"
43+
class="mx-auto d-block"
44+
style="cursor: pointer;"
45+
tabindex="-1"
46+
role=''
47+
on:keydown={() => {}}
48+
on:click={() => chatWithAgent()}
49+
/>
1450
<h5 class="mt-1 mb-1"><InPlaceEdit bind:value={agent.name}/></h5>
1551
<p class="text-muted mb-0">Updated at {format(agent.updated_datetime, 'time')}</p>
1652
</div>
@@ -51,9 +87,38 @@
5187
<th class="agent-prop-key">Profiles</th>
5288
<td>
5389
<div class="agent-profile-container">
54-
{#each agent.profiles as profile}
55-
<div class="profile-name">{profile}</div>
90+
{#each profiles as profile, index}
91+
<div style="display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 5px;">
92+
<input
93+
class="form-control"
94+
style="flex: 0.9; border: none; padding-left: 0px;"
95+
type="text"
96+
placeholder="Typing here..."
97+
bind:value={profile} maxlength={30} />
98+
<div style="flex: 0.1; display: flex; align-items: center;">
99+
<i
100+
class="bx bxs-no-entry"
101+
style="cursor: pointer; font-size: 18px; color: red;"
102+
role="link"
103+
tabindex="0"
104+
on:keydown={() => {}}
105+
on:click={() => removeProfile(index)}
106+
/>
107+
</div>
108+
</div>
56109
{/each}
110+
{#if profiles?.length < profileLimit}
111+
<div style="font-size: 20px;">
112+
<i
113+
class="bx bx bx-list-plus"
114+
style="cursor: pointer;"
115+
role="link"
116+
tabindex="0"
117+
on:keydown={() => {}}
118+
on:click={() => addProfile()}
119+
/>
120+
</div>
121+
{/if}
57122
</div>
58123
</td>
59124
</tr>

0 commit comments

Comments
 (0)