Skip to content

Commit 6835aa8

Browse files
authored
Merge pull request #287 from iceljc/features/refine-chat-window
add event rules
2 parents 894ebb1 + 0fdc984 commit 6835aa8

File tree

14 files changed

+416
-40
lines changed

14 files changed

+416
-40
lines changed

src/lib/helpers/types/agentTypes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
* @property {AgentTemplate[]} templates
6262
* @property {Object[]} responses
6363
* @property {RoutingRule[]} routing_rules
64+
* @property {AgentEventRule[]} event_rules
6465
* @property {AgentWelcomeInfo} welcome_info - Welcome information.
6566
* @property {string[]?} [actions]
6667
*/
@@ -135,6 +136,15 @@
135136
* @property {boolean} disabled
136137
*/
137138

139+
/**
140+
* @typedef {Object} AgentEventRule
141+
* @property {string} name
142+
* @property {string} event_name
143+
* @property {string} event_type
144+
* @property {string?} [displayName]
145+
* @property {boolean} disabled
146+
*/
147+
138148
/**
139149
* @typedef {Object} UtilityBase
140150
* @property {string} name

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616

1717
.agent-prop-list-container {
18-
width: 85%;
18+
width: 95%;
1919
max-width: 100%;
2020

2121
.edit-wrapper {
@@ -51,11 +51,28 @@
5151
}
5252
}
5353

54+
.vertical-flexible {
55+
max-height: 200px;
56+
overflow-y: auto;
57+
scrollbar-width: none;
58+
}
59+
5460
.agent-detail-sections {
61+
.card {
62+
margin-bottom: 0px !important;
63+
}
64+
5565
.section-min-width {
5666
min-width: 300px;
5767
}
5868

69+
.agent-col {
70+
display: flex;
71+
flex-direction: column;
72+
gap: 10px;
73+
margin-bottom: 10px;
74+
}
75+
5976
.agent-detail-section {
6077
@media (max-width: 423px) {
6178
height: fit-content;

src/lib/services/agent-service.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,21 @@ export async function createAgent(agent) {
8383
}
8484

8585
/**
86-
* Get agent utilities
86+
* Get agent utility options
8787
* @returns {Promise<import('$agentTypes').AgentUtility[]>}
8888
*/
8989
export async function getAgentUtilityOptions() {
9090
const url = endpoints.agentUtilityOptionsUrl;
9191
const response = await axios.get(url);
9292
return response.data;
93+
}
94+
95+
/**
96+
* Get agent event rule options
97+
* @returns {Promise<import('$agentTypes').AgentEventRule[]>}
98+
*/
99+
export async function getAgentEventRuleOptions() {
100+
const url = endpoints.agentEventRuleOptionsUrl;
101+
const response = await axios.get(url);
102+
return response.data;
93103
}

src/lib/services/api-endpoints.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const endpoints = {
3434
agentRefreshUrl: `${host}/refresh-agents`,
3535
agentCreateUrl: `${host}/agent`,
3636
agentUtilityOptionsUrl: `${host}/agent/utility/options`,
37+
agentEventRuleOptionsUrl: `${host}/agent/event-rule/options`,
3738

3839
// agent task
3940
agentTaskListUrl: `${host}/agent/tasks`,

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

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,16 @@
77
import Breadcrumb from '$lib/common/Breadcrumb.svelte';
88
import HeadTitle from '$lib/common/HeadTitle.svelte';
99
import LoadingToComplete from '$lib/common/LoadingToComplete.svelte';
10-
import AgentPrompt from './agent-prompt.svelte';
11-
import AgentOverview from './agent-overview.svelte';
12-
import AgentRouting from './agent-routing.svelte';
13-
import AgentFunction from './agent-function.svelte';
14-
import AgentLlmConfig from './agent-llm-config.svelte';
10+
import AgentPrompt from './agent-components/agent-prompt.svelte';
11+
import AgentOverview from './agent-components/agent-overview.svelte';
12+
import AgentFunction from './agent-components/agent-function.svelte';
13+
import AgentTabs from './agent-tabs.svelte';
1514
import { page } from '$app/stores';
1615
import { deleteAgent, getAgent, saveAgent } from '$lib/services/agent-service.js';
1716
import { onMount } from 'svelte';
1817
import { _ } from 'svelte-i18n'
1918
import Swal from 'sweetalert2'
2019
import { goto } from '$app/navigation';
21-
import AgentUtility from './agent-utility.svelte';
22-
import AgentKnowledgeBase from './agent-knowledge-base.svelte';
2320
import { AgentExtensions } from '$lib/helpers/utils/agent';
2421
2522
@@ -30,9 +27,7 @@
3027
/** @type {any} */
3128
let agentPromptCmp = null;
3229
/** @type {any} */
33-
let agentUtilityCmp = null;
34-
/** @type {any} */
35-
let agentKnowledgeBaseCmp = null;
30+
let agentTabsCmp = null;
3631
3732
/** @type {boolean} */
3833
let isLoading = false;
@@ -72,8 +67,7 @@
7267
function handleAgentUpdate() {
7368
fetchJsonContent();
7469
fetchPrompts();
75-
fetchUtilties();
76-
fetchKnowledgeBases();
70+
fetchTabData();
7771
7872
agent = {
7973
...agent,
@@ -83,6 +77,7 @@
8377
profiles: agent.profiles?.filter((x, idx, self) => x?.trim()?.length > 0 && self.indexOf(x) === idx) || [],
8478
utilities: agent.utilities || [],
8579
knowledge_bases: agent.knowledge_bases || [],
80+
event_rules: agent.event_rules || [],
8681
max_message_count: Number(agent.max_message_count) > 0 ? Number(agent.max_message_count) : null
8782
};
8883
isLoading = true;
@@ -121,14 +116,13 @@
121116
agent.channel_instructions = obj.channelPrompts || [];
122117
}
123118
124-
function fetchUtilties() {
125-
const list = agentUtilityCmp?.fetchUtilities();
126-
agent.utilities = list || [];
127-
}
128-
129-
function fetchKnowledgeBases() {
130-
const list = agentKnowledgeBaseCmp?.fetchKnowledgeBases();
131-
agent.knowledge_bases = list || [];
119+
function fetchTabData() {
120+
const data = agentTabsCmp?.fetchData();
121+
if (data) {
122+
agent.utilities = data.utilities || [];
123+
agent.knowledge_bases = data.knwoledgebases || [];
124+
agent.event_rules = data.eventRules || [];
125+
}
132126
}
133127
134128
function refreshChannelPrompts() {
@@ -163,25 +157,17 @@
163157
<LoadingToComplete isLoading={isLoading} isComplete={isComplete} isError={isError} />
164158
165159
{#if agent}
160+
<div>
166161
<Row class="agent-detail-sections">
167-
<Col class="section-min-width agent-overview" style="flex: 35%;">
162+
<Col class="section-min-width agent-col" style="flex: 40%;">
168163
<div class="agent-detail-section">
169164
<AgentOverview agent={agent} profiles={agent.profiles || []} />
170165
</div>
171166
<div class="agent-detail-section">
172-
<AgentLlmConfig agent={agent} />
173-
{#if agent.routing_rules?.length > 0}
174-
<AgentRouting agent={agent} />
175-
{/if}
176-
</div>
177-
<div class="agent-detail-section">
178-
<AgentUtility bind:this={agentUtilityCmp} agent={agent} />
179-
</div>
180-
<div class="agent-detail-section">
181-
<AgentKnowledgeBase bind:this={agentKnowledgeBaseCmp} agent={agent} />
167+
<AgentTabs bind:this={agentTabsCmp} agent={agent} />
182168
</div>
183169
</Col>
184-
<Col class="section-min-width" style="flex: 65%;">
170+
<Col class="section-min-width agent-col" style="flex: 60%;">
185171
<div class="agent-detail-section">
186172
<AgentPrompt bind:this={agentPromptCmp} agent={agent} />
187173
</div>
@@ -199,4 +185,5 @@
199185
</div>
200186
</Row>
201187
{/if}
188+
</div>
202189
{/if}

0 commit comments

Comments
 (0)