Skip to content

Commit

Permalink
Optimize StreamingLog
Browse files Browse the repository at this point in the history
  • Loading branch information
Oceania2018 committed Jan 24, 2024
1 parent 438b765 commit 0129f86
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 139 deletions.
2 changes: 2 additions & 0 deletions src/lib/helpers/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@
* @property {boolean} disabled
* @property {boolean} is_public
* @property {boolean} is_router
* @property {boolean} is_host
* @property {string} icon_url - Icon
* @property {boolean} allow_routing
* @property {string[]} profiles - The agent profiles.
* @property {Date} created_datetime
* @property {Date} updated_datetime
* @property {AgentLlmConfig} llm_config - LLM settings.
Expand Down
6 changes: 4 additions & 2 deletions src/routes/chat/[agentId]/[conversationId]/chat-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,21 @@
<div class="col-md-8 col-5">
<ul class="list-inline user-chat-nav text-end mb-0">
{#if !isLoadLog}
<li class="list-inline-item">
<Dropdown>
<DropdownToggle tag="button" class="nav-btn dropdown-toggle" color="">
<i class="bx bx-dots-horizontal-rounded" />
</DropdownToggle>
<DropdownMenu class="dropdown-menu-end">
{#if !isLoadLog}
<DropdownItem on:click={viewFullLogHandler} >View Log</DropdownItem>
{/if}
<DropdownItem on:click={newConversationHandler} >New Conversation</DropdownItem>
</DropdownMenu>
</Dropdown>
</li>
{/if}
<li class="list-inline-item d-sm-inline-block">
<button type="submit" class="btn btn-primary btn-rounded chat-send waves-effect waves-light"
on:click={close}
Expand Down
8 changes: 7 additions & 1 deletion src/routes/page/agent/[agentId]/agent-overview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { Button, Card, CardBody, CardHeader, Col, Table } from '@sveltestrap/sveltestrap';
import InPlaceEdit from '$lib/common/InPlaceEdit.svelte'
import { format } from '$lib/helpers/datetime';
import AgentLlmConfig from './agent-llm-config.svelte';
/** @type {import('$types').AgentModel} */
export let agent;
Expand Down Expand Up @@ -50,7 +51,12 @@
</tr>
<tr>
<th>Profiles</th>
<td><span class="badge badge-soft-success mx-1">phone</span><span class="badge badge-soft-success mx-1">webchat</span></td>
<td>
{#each agent.profiles as profile}
<input class="form-control" type="text" value={profile} />
<a href={null} class="btn btn-danger">Delete</a>
{/each}
</td>
</tr>
<tr>
<th>Status</th>
Expand Down
22 changes: 6 additions & 16 deletions src/routes/page/agent/router/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import HeadTitle from '$lib/common/HeadTitle.svelte';
import { getAgents } from '$lib/services/agent-service.js';
import RoutingFlow from './routing-flow.svelte'
import RoutingConfiguration from './router-configuration.svelte';
import AgentConfiguration from './agent-configuration.svelte';
import { onMount } from 'svelte';
/** @type {import('$types').AgentModel} */
let router;
/** @type {import('$types').AgentModel[]} */
let routers;
let isRouterNodeSelected = false;
let isAgentNodeSelected = false;
Expand All @@ -26,7 +24,7 @@
async function getRouter() {
const response = await getAgents(filter);
if (response.items?.length > 0) {
router = response.items[0];
routers = response.items;
}
};
Expand All @@ -52,22 +50,14 @@
<HeadTitle title="Router" />
<Breadcrumb title="Agent" pagetitle="Router" />
{#if router}
{#if routers}
<Row>
<Col lg={9}>
<RoutingFlow router={router}
<Col>
<RoutingFlow routers={routers}
on:userNodeSelected={(e) => handleUserNodeSelected()}
on:routerNodeSelected={(e) => handleRouterNodeSelected(e.detail.agent)}
on:agentNodeSelected={(e) => handleAgentNodeSelected(e.detail.agent)}/>
</Col>
<Col lg={3}>
{#if isAgentNodeSelected}
<AgentConfiguration agent={router} />
{/if}
{#if isRouterNodeSelected}
<RoutingConfiguration router={router} />
{/if}
</Col>
</Row>
{/if}
53 changes: 0 additions & 53 deletions src/routes/page/agent/router/agent-configuration.svelte

This file was deleted.

41 changes: 0 additions & 41 deletions src/routes/page/agent/router/router-configuration.svelte

This file was deleted.

49 changes: 23 additions & 26 deletions src/routes/page/agent/router/routing-flow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,18 @@
/** @type {import('$types').AgentFilter} */
const filter = {
pager: { page: 1, size: 20, count: 0 },
isRouter: false,
isEvaluator: false,
disabled: false,
allowRouting: true
};
/** @type {import('$types').AgentModel} */
export let router;
/** @type {import('$types').AgentModel[]} */
export let routers;
const dispatch = createEventDispatcher();
onMount(async () => {
const response = await getAgents(filter);
agents = response?.items || [];
// add a "New Agent" button
agents.push({
name: "New Agent",
allow_routing: true
});
const container = document.getElementById("drawflow");
if (!!container) {
const editor = new Drawflow(container);
Expand All @@ -49,7 +40,7 @@
};
let posX = 0;
let nodeSpace = 200;
let nodeSpace = 250;
let nodeId = 1;
let posY = 100 * agents.length / 2 + 50;
Expand All @@ -61,22 +52,28 @@
posX += nodeSpace;
nodeId++;
let routerNodeId = nodeId;
editor.addNode('router', 1, 1, posX, posY, 'router', data, `Router (${router.name})`, false);
// connect user and router
editor.addConnection(1, nodeId, `output_1`, `input_1`);
let hostNodeId = nodeId;
let routerPosY = posY;
routers.forEach(router => {
const profiles = router.profiles.join(', ');
if (router.is_host) {
editor.addNode('host', 1, 1, posX, routerPosY, 'router', data, `${router.name} (Host Router) ${profiles}`, false);
hostNodeId = nodeId;
} else {
editor.addNode('router', 1, 1, posX, routerPosY, 'router', data, `${router.name} (Routing Agent) ${profiles}`, false);
}
// connect user and router
editor.addConnection(1, nodeId, `output_1`, `input_1`);
routerPosY += 100;
nodeId++;
});
posY = 100;
posX += nodeSpace;
nodeId++;
agents.forEach(agent => {
if (!agent.id) {
// add a "New Agent" button
editor.addNode('new-agent', 1, 0, posX, posY, 'new-node', data, `New Agent`, false);
} else {
editor.addNode('agent', 1, 0, posX, posY, 'enabled-node', data, `Agent (${agent.name})`, false);
}
editor.addConnection(2, nodeId, `output_1`, `input_1`);
agents.forEach(agent => {
const profiles = agent.profiles.join(', ');
editor.addNode('agent', 1, 0, posX, posY, 'enabled-node', data, `${agent.name} (Task Agent) ${profiles}`, false);
editor.addConnection(hostNodeId, nodeId, `output_1`, `input_1`);
posY += 100;
nodeId++;
});
Expand All @@ -87,7 +84,7 @@
if (id == userNodeId) {
dispatch('userNodeSelected', {});
} else if (id == routerNodeId) {
dispatch('routerNodeSelected', {agent: router});
dispatch('routerNodeSelected', {});
} else {
dispatch('agentNodeSelected', {agent: agents[id - routerNodeId - 1]});
}
Expand Down

0 comments on commit 0129f86

Please sign in to comment.