diff --git a/src/routes/page/agent/[agentId]/+page.svelte b/src/routes/page/agent/[agentId]/+page.svelte
index 6aa828e3..528165a2 100644
--- a/src/routes/page/agent/[agentId]/+page.svelte
+++ b/src/routes/page/agent/[agentId]/+page.svelte
@@ -19,31 +19,45 @@
/** @type {import('$types').AgentModel} */
let agent;
+ /** @type {any} */
+ let agentFunctionCmp = null;
onMount(async () => {
agent = await getAgent(params.agentId);
});
async function handleAgentUpdate() {
+ fetchJsonContent();
const result = await saveAgent(agent)
}
+
+ function fetchJsonContent() {
+ const content = agentFunctionCmp?.fetchContent();
+ const textContent = JSON.parse(content?.text || "{}");
+ const jsonContent = JSON.parse(JSON.stringify(content?.json || {}));
+ agent.functions = textContent?.functions?.length > 0 ? textContent.functions :
+ (jsonContent?.functions?.length > 0 ? jsonContent?.functions : []);
+ agent.responses = textContent?.responses?.length > 0 ? textContent.responses :
+ (jsonContent?.responses?.length > 0 ? jsonContent?.responses : []);
+ agent.templates = textContent?.templates?.length > 0 ? textContent.templates :
+ (jsonContent?.templates?.length > 0 ? jsonContent?.templates : []);
+ }