|
@@ -307,15 +307,25 @@ function createSystemPrompt(prompt) {
|
|
|
? "prompt-item event-prompt"
|
|
? "prompt-item event-prompt"
|
|
|
: "prompt-item";
|
|
: "prompt-item";
|
|
|
item.dataset.promptKind = promptItem.prompt_kind;
|
|
item.dataset.promptKind = promptItem.prompt_kind;
|
|
|
|
|
+ item.dataset.promptRole = promptItem.role;
|
|
|
item.draggable = true;
|
|
item.draggable = true;
|
|
|
|
|
|
|
|
const head = document.createElement("div");
|
|
const head = document.createElement("div");
|
|
|
head.className = "prompt-item-head";
|
|
head.className = "prompt-item-head";
|
|
|
|
|
|
|
|
|
|
+ const meta = document.createElement("div");
|
|
|
|
|
+ meta.className = "prompt-meta";
|
|
|
|
|
+
|
|
|
|
|
+ const type = document.createElement("span");
|
|
|
|
|
+ type.className = "prompt-type";
|
|
|
|
|
+ type.textContent = `type: ${promptItem.role}`;
|
|
|
|
|
+
|
|
|
const title = document.createElement("span");
|
|
const title = document.createElement("span");
|
|
|
|
|
+ title.className = "prompt-title";
|
|
|
title.textContent = promptItem.prompt_kind === "event_agent_system"
|
|
title.textContent = promptItem.prompt_kind === "event_agent_system"
|
|
|
- ? "EventAgent System Prompt"
|
|
|
|
|
- : "Custom Prompt";
|
|
|
|
|
|
|
+ ? "EventAgent Rules"
|
|
|
|
|
+ : "Custom";
|
|
|
|
|
+ meta.append(type, title);
|
|
|
|
|
|
|
|
const actions = document.createElement("div");
|
|
const actions = document.createElement("div");
|
|
|
actions.className = "prompt-actions";
|
|
actions.className = "prompt-actions";
|
|
@@ -342,11 +352,11 @@ function createSystemPrompt(prompt) {
|
|
|
actions.append(deleteButton);
|
|
actions.append(deleteButton);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- head.append(title, actions);
|
|
|
|
|
|
|
+ head.append(meta, actions);
|
|
|
|
|
|
|
|
const textarea = document.createElement("textarea");
|
|
const textarea = document.createElement("textarea");
|
|
|
textarea.className = "system-prompt";
|
|
textarea.className = "system-prompt";
|
|
|
- textarea.rows = promptItem.prompt_kind === "event_agent_system" ? 7 : 4;
|
|
|
|
|
|
|
+ textarea.rows = promptItem.prompt_kind === "event_agent_system" ? 7 : 3;
|
|
|
textarea.value = promptItem.content;
|
|
textarea.value = promptItem.content;
|
|
|
textarea.readOnly = promptItem.prompt_kind === "event_agent_system";
|
|
textarea.readOnly = promptItem.prompt_kind === "event_agent_system";
|
|
|
|
|
|
|
@@ -389,6 +399,7 @@ function buildPromptItems() {
|
|
|
return [...systemPrompts.querySelectorAll(".prompt-item")]
|
|
return [...systemPrompts.querySelectorAll(".prompt-item")]
|
|
|
.map((item) => ({
|
|
.map((item) => ({
|
|
|
prompt_kind: item.dataset.promptKind || "custom",
|
|
prompt_kind: item.dataset.promptKind || "custom",
|
|
|
|
|
+ role: item.dataset.promptRole || "system",
|
|
|
content: item.querySelector(".system-prompt").value.trim(),
|
|
content: item.querySelector(".system-prompt").value.trim(),
|
|
|
}))
|
|
}))
|
|
|
.filter((item) => item.prompt_kind === "event_agent_system" || item.content);
|
|
.filter((item) => item.prompt_kind === "event_agent_system" || item.content);
|
|
@@ -413,7 +424,7 @@ function normalizePromptItems(prompts) {
|
|
|
normalized.push({ prompt_kind: "event_agent_system", content: "" });
|
|
normalized.push({ prompt_kind: "event_agent_system", content: "" });
|
|
|
}
|
|
}
|
|
|
if (!normalized.some((prompt) => prompt.prompt_kind === "custom")) {
|
|
if (!normalized.some((prompt) => prompt.prompt_kind === "custom")) {
|
|
|
- normalized.unshift({ prompt_kind: "custom", content: "" });
|
|
|
|
|
|
|
+ normalized.unshift({ prompt_kind: "custom", role: "system", content: "" });
|
|
|
}
|
|
}
|
|
|
return normalized;
|
|
return normalized;
|
|
|
}
|
|
}
|
|
@@ -424,11 +435,13 @@ function normalizePromptItem(prompt) {
|
|
|
prompt_kind: prompt.prompt_kind === "event_agent_system"
|
|
prompt_kind: prompt.prompt_kind === "event_agent_system"
|
|
|
? "event_agent_system"
|
|
? "event_agent_system"
|
|
|
: "custom",
|
|
: "custom",
|
|
|
|
|
+ role: "system",
|
|
|
content: prompt.content || "",
|
|
content: prompt.content || "",
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
return {
|
|
return {
|
|
|
prompt_kind: "custom",
|
|
prompt_kind: "custom",
|
|
|
|
|
+ role: "system",
|
|
|
content: prompt || "",
|
|
content: prompt || "",
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|