|
18 | 18 | import { _ } from 'svelte-i18n' |
19 | 19 | import Swal from 'sweetalert2' |
20 | 20 | import { goto } from '$app/navigation'; |
| 21 | + import AgentUtility from './agent-utility.svelte'; |
| 22 | + import { AgentExtensions } from '$lib/helpers/utils/agent'; |
21 | 23 | |
22 | 24 | |
23 | 25 | /** @type {import('$agentTypes').AgentModel} */ |
|
26 | 28 | let agentFunctionCmp = null; |
27 | 29 | /** @type {any} */ |
28 | 30 | let agentPromptCmp = null; |
| 31 | + /** @type {any} */ |
| 32 | + let agentUtilityCmp = null; |
29 | 33 |
|
30 | 34 | /** @type {boolean} */ |
31 | 35 | let isLoading = false; |
|
65 | 69 | function handleAgentUpdate() { |
66 | 70 | fetchJsonContent(); |
67 | 71 | fetchPrompts(); |
| 72 | + fetchUtilties(); |
68 | 73 |
|
69 | 74 | agent = { |
70 | 75 | ...agent, |
71 | 76 | description: agent.description || '', |
72 | 77 | instruction: agent.instruction || '', |
73 | 78 | channel_instructions: agent.channel_instructions || [], |
74 | 79 | profiles: agent.profiles?.filter((x, idx, self) => x?.trim()?.length > 0 && self.indexOf(x) === idx) || [], |
75 | | - utilities: agent.utilities?.filter((x, idx, self) => x?.trim()?.length > 0 && self.indexOf(x) === idx) || [] |
| 80 | + utilities: agent.utilities || [] |
76 | 81 | }; |
77 | 82 | isLoading = true; |
78 | 83 | saveAgent(agent).then(res => { |
|
110 | 115 | agent.channel_instructions = obj.channelPrompts || []; |
111 | 116 | } |
112 | 117 |
|
| 118 | + function fetchUtilties() { |
| 119 | + const list = agentUtilityCmp?.fetchUtilities(); |
| 120 | + agent.utilities = list || []; |
| 121 | + } |
| 122 | +
|
113 | 123 | function refreshChannelPrompts() { |
114 | 124 | agentPromptCmp?.refreshChannelPrompts(); |
115 | 125 | } |
|
145 | 155 | <Row class="agent-detail-sections"> |
146 | 156 | <Col class="section-min-width agent-overview" style="flex: 35%;"> |
147 | 157 | <div class="agent-detail-section"> |
148 | | - <AgentOverview agent={agent} profiles={agent.profiles || []} utilities={agent.utilities || []} /> |
| 158 | + <AgentOverview agent={agent} profiles={agent.profiles || []} /> |
149 | 159 | </div> |
150 | | -
|
151 | 160 | <div class="agent-detail-section"> |
152 | 161 | <AgentLlmConfig agent={agent} /> |
153 | 162 | {#if agent.routing_rules?.length > 0} |
154 | 163 | <AgentRouting agent={agent} /> |
155 | 164 | {/if} |
156 | 165 | </div> |
| 166 | + <div class="agent-detail-section"> |
| 167 | + <AgentUtility bind:this={agentUtilityCmp} agent={agent} /> |
| 168 | + </div> |
157 | 169 | </Col> |
158 | 170 | <Col class="section-min-width" style="flex: 65%;"> |
159 | 171 | <div class="agent-detail-section"> |
|
165 | 177 | </Col> |
166 | 178 | </Row> |
167 | 179 |
|
168 | | - {#if !!agent?.editable} |
| 180 | + {#if !!AgentExtensions.editable(agent)} |
169 | 181 | <Row> |
170 | 182 | <div class="hstack gap-2 my-4"> |
171 | 183 | <Button class="btn btn-soft-primary" on:click={() => updateCurrentAgent()}>{$_('Save Agent')}</Button> |
|
0 commit comments