Skip to content

Commit f335003

Browse files
authored
Merge pull request #158 from iceljc/features/refine-chat-window
direct to agent page
2 parents bbe6a8c + 35ee008 commit f335003

4 files changed

Lines changed: 31 additions & 23 deletions

File tree

src/lib/helpers/utils/common.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ export function range(size = 3, startAt = 0) {
88
*/
99
export function buildUrl(baseUrl, relativePath) {
1010
return new URL(relativePath, baseUrl);
11+
}
12+
13+
/** @param {string} agentId */
14+
export function directToAgentPage(agentId) {
15+
if (!agentId) return;
16+
17+
window.open(`/page/agent/${agentId}`);
1118
}
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
11
<script>
2+
import { directToAgentPage } from '$lib/helpers/utils/common';
3+
24
/** @type {import('$types').AgentModel} */
35
export let agent;
46
</script>
57

68
<div>
79
<div class="chat-agent-row">
8-
<h3 class="text-primary fw-bold">
9-
{agent?.name || ''}
10+
<!-- svelte-ignore a11y-click-events-have-key-events -->
11+
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
12+
<h3
13+
class="text-primary fw-bold"
14+
on:click={() => directToAgentPage(agent?.id)}
15+
>
16+
<span class="clickable">{agent?.name || ''}</span>
1017
</h3>
1118
</div>
1219
<div class="chat-agent-row">
1320
<div class="text-secondary">
14-
{agent?.description || ''}
21+
<span>{agent?.description || ''}</span>
1522
</div>
1623
</div>
1724
<div class="chat-agent-row">
1825
<div>
19-
{agent?.llm_config?.provider || ''}{!!agent?.llm_config?.provider ? ',': ''} {agent?.llm_config?.model || ''}
26+
<span>{agent?.llm_config?.provider || ''}{!!agent?.llm_config?.provider ? ',': ''} {agent?.llm_config?.model || ''}</span>
2027
</div>
2128
</div>
2229
<div class="chat-agent-row">
2330
<div>
24-
<span>
25-
{agent?.profiles?.length || 0} {agent?.profiles?.length > 1 ? 'profiles' : 'profile'}{!!agent?.profiles ? ', ' : ''}
26-
{agent?.functions?.length || 0} {agent?.functions?.length > 1 ? 'functions' : 'function'}{!!agent?.functions ? ', ' : ''}
27-
{agent?.templates?.length || 0} {agent?.templates?.length > 1 ? 'templates' : 'template'}{!!agent?.templates ? ', ' : ''}
28-
{agent?.utilities?.length || 0} {agent?.utilities?.length > 1 ? 'utilities' : 'utility'}
29-
</span>
31+
{#if !!agent?.profiles}
32+
<span>{agent?.profiles?.length || 0} {agent?.profiles?.length > 1 ? 'profiles' : 'profile'}{', '}</span>
33+
{/if}
34+
{#if !!agent?.functions}
35+
<span>{agent?.functions?.length || 0} {agent?.functions?.length > 1 ? 'functions' : 'function'}{', '}</span>
36+
{/if}
37+
{#if !!agent?.utilities}
38+
<span>{agent?.utilities?.length || 0} {agent?.utilities?.length > 1 ? 'utilities' : 'utility'}</span>
39+
{/if}
3040
</div>
3141
</div>
3242
</div>

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import Markdown from "$lib/common/Markdown.svelte";
55
import { ContentLogSource } from '$lib/helpers/enums';
66
import { utcToLocal } from '$lib/helpers/datetime';
7+
import { directToAgentPage } from '$lib/helpers/utils/common';
78
89
/** @type {import('$types').ConversationContentLogModel} */
910
export let data;
@@ -33,11 +34,6 @@
3334
e.preventDefault();
3435
is_collapsed = !is_collapsed;
3536
}
36-
37-
/** @param {string} agentId */
38-
function directToAgentDetailPage(agentId) {
39-
window.open(`/page/agent/${agentId}`);
40-
}
4137
</script>
4238

4339
<div class="log-element rounded" style="padding: 3px;" id={`content-log-${data.message_id}`}>
@@ -46,7 +42,7 @@
4642
{#if data?.name?.length > 0}
4743
<span class="h4">
4844
{#if data?.agent_id?.length > 0}
49-
<Link class="text-white" on:click={() => directToAgentDetailPage(data.agent_id)}>
45+
<Link class="text-white" on:click={() => directToAgentPage(data.agent_id)}>
5046
{data.name}
5147
</Link>
5248
{:else}

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
<script>
22
import CollapsibleCard from "$lib/common/CollapsibleCard.svelte";
3+
import { directToAgentPage } from "$lib/helpers/utils/common";
34
import { Card, CardBody, Table } from "@sveltestrap/sveltestrap";
45
56
/** @type {import('$types').AgentModel} */
67
export let agent;
7-
8-
/** @param {string} agentId */
9-
function redirectToAgent(agentId) {
10-
window.open(`/page/agent/${agentId}`);
11-
}
12-
138
</script>
149

1510
<Card>
@@ -53,7 +48,7 @@
5348
{#if !!rule.redirectTo}
5449
<tr>
5550
<th class="agent-prop-key">Redirect to Agent</th>
56-
<td style="cursor: pointer;" on:click={() => redirectToAgent(rule.redirectTo)}>
51+
<td style="cursor: pointer;" on:click={() => directToAgentPage(rule.redirectTo)}>
5752
{rule.redirect_to_agent || ''}
5853
</td>
5954
</tr>

0 commit comments

Comments
 (0)