Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/helpers/types/agentTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* @property {AgentTemplate[]} templates
* @property {Object[]} responses
* @property {RoutingRule[]} routing_rules
* @property {AgentEventRule[]} event_rules
* @property {AgentRule[]} rules
* @property {AgentWelcomeInfo} welcome_info - Welcome information.
* @property {string[]?} [actions]
*/
Expand Down Expand Up @@ -137,7 +137,7 @@
*/

/**
* @typedef {Object} AgentEventRule
* @typedef {Object} AgentRule
* @property {string} name
* @property {string} event_name
* @property {string} entity_type
Expand Down
8 changes: 4 additions & 4 deletions src/lib/services/agent-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ export async function getAgentUtilityOptions() {
}

/**
* Get agent event rule options
* @returns {Promise<import('$agentTypes').AgentEventRule[]>}
* Get agent rule options
* @returns {Promise<import('$agentTypes').AgentRule[]>}
*/
export async function getAgentEventRuleOptions() {
const url = endpoints.agentEventRuleOptionsUrl;
export async function getAgentRuleOptions() {
const url = endpoints.agentRuleOptionsUrl;
const response = await axios.get(url);
return response.data;
}
2 changes: 1 addition & 1 deletion src/lib/services/api-endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const endpoints = {
agentRefreshUrl: `${host}/refresh-agents`,
agentCreateUrl: `${host}/agent`,
agentUtilityOptionsUrl: `${host}/agent/utility/options`,
agentEventRuleOptionsUrl: `${host}/agent/event-rule/options`,
agentRuleOptionsUrl: `${host}/agent/rule/options`,

// agent task
agentTaskListUrl: `${host}/agent/tasks`,
Expand Down
4 changes: 2 additions & 2 deletions src/routes/page/agent/[agentId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
profiles: agent.profiles?.filter((x, idx, self) => x?.trim()?.length > 0 && self.indexOf(x) === idx) || [],
utilities: agent.utilities || [],
knowledge_bases: agent.knowledge_bases || [],
event_rules: agent.event_rules || [],
rules: agent.rules || [],
max_message_count: Number(agent.max_message_count) > 0 ? Number(agent.max_message_count) : null
};
isLoading = true;
Expand Down Expand Up @@ -121,7 +121,7 @@
if (data) {
agent.utilities = data.utilities || [];
agent.knowledge_bases = data.knwoledgebases || [];
agent.event_rules = data.eventRules || [];
agent.rules = data.rules || [];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Card>
<CardBody>
<div class="text-center">
<h5 class="mt-1 mb-3">Routing Rules</h5>
<h5 class="mt-1 mb-3">Routing</h5>
</div>

{#each agent.routing_rules as rule, idx (idx)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script>
import { onMount } from 'svelte';
import { Card, CardBody, Input, Button } from '@sveltestrap/sveltestrap';
import { getAgentEventRuleOptions } from '$lib/services/agent-service';
import { getAgentRuleOptions } from '$lib/services/agent-service';

const limit = 5;
const textLimit = 50;

/** @type {import('$agentTypes').AgentModel} */
export let agent;

export const fetchEventRules = () => {
export const fetchRules = () => {
const candidates = innerRules?.filter(x => !!x.name)?.map(x => {
return {
name: x.name,
Expand All @@ -19,7 +19,7 @@
};
});

/** @type {import('$agentTypes').AgentEventRule[]} */
/** @type {import('$agentTypes').AgentRule[]} */
const rules = [];
const unique = new Set();
candidates.forEach(x => {
Expand All @@ -36,11 +36,11 @@
/** @type {any[]} */
let ruleOptions = [];

/** @type {import('$agentTypes').AgentEventRule[]} */
/** @type {import('$agentTypes').AgentRule[]} */
let innerRules = [];

onMount(async () =>{
getAgentEventRuleOptions().then(data => {
getAgentRuleOptions().then(data => {
const list = data?.map(x => {
return {
name: x.name,
Expand All @@ -56,7 +56,7 @@
});

function init() {
const list = agent.event_rules?.map(x => {
const list = agent.rules?.map(x => {
return {
...x,
displayName: "",
Expand Down Expand Up @@ -128,7 +128,7 @@
}


/** @param {import('$agentTypes').AgentEventRule[]} list */
/** @param {import('$agentTypes').AgentRule[]} list */
function refresh(list) {
innerRules = list?.map(x => {
return {
Expand All @@ -146,15 +146,15 @@
<Card>
<CardBody>
<div class="text-center">
<h5 class="mt-1 mb-3">Event Rules</h5>
<h5 class="mt-1 mb-3">Rules</h5>
</div>

<div class="agent-utility-container">
{#each innerRules as rule, uid (uid)}
<div class="utility-wrapper">
<div class="utility-row utility-row-primary">
<div class="utility-label fw-bold">
<div class="line-align-center">{`Collection #${uid + 1}`}</div>
<div class="line-align-center">{`Rule #${uid + 1}`}</div>
<div class="utility-tooltip">
<div class="line-align-center">
<Input
Expand Down Expand Up @@ -247,7 +247,7 @@
<Button color="primary" on:click={() => addRule()}>
<span>
<i class="bx bx-plus" />
<span>Add Event Rule</span>
<span>Add Rule</span>
</span>
</Button>
</div>
Expand Down
12 changes: 6 additions & 6 deletions src/routes/page/agent/[agentId]/agent-tabs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
import AgentUtility from './agent-components/agent-utility.svelte';
import AgentKnowledgeBase from './agent-components/agent-knowledge-base.svelte';
import AgentRouting from './agent-components/agent-routing.svelte';
import AgentEventRule from './agent-components/agent-event-rule.svelte';
import AgentEventRule from './agent-components/agent-rule.svelte';

/** @type {import('$agentTypes').AgentModel} */
export let agent;

export const fetchData = () => {
const utilities = agentUtilityCmp?.fetchUtilities();
const knwoledgebases = agentKnowledgeBaseCmp?.fetchKnowledgeBases();
const eventRules = agentEventRuleCmp?.fetchEventRules();
const rules = agentEventRuleCmp?.fetchRules();

return {
utilities: utilities || [],
knwoledgebases: knwoledgebases || [],
eventRules: eventRules || []
rules: rules || []
};
};

Expand All @@ -37,10 +37,10 @@
/** @type {any[]}*/
let tabs = [
{ name: 'agent-llm-config', displayText: 'LLm Config' },
{ name: 'agent-routing-rule', displayText: 'Routing Rules' },
{ name: 'agent-routing-rule', displayText: 'Routing' },
{ name: 'agent-utility', displayText: 'Utilities' },
{ name: 'agent-knowledgebase', displayText: 'Knowledge Bases' },
{ name: 'agent-event-rule', displayText: 'Event Rules' }
{ name: 'agent-knowledgebase', displayText: 'Knowledge Base' },
{ name: 'agent-event-rule', displayText: 'Rules' }
];

onMount(() => {
Expand Down
Loading