gpt-engineer-app[bot] commited on
Commit ·
1eb3593
1
Parent(s): 0b2c746
Changes
Browse files
src/server/incidents.functions.ts
CHANGED
|
@@ -82,6 +82,20 @@ export const analyzeIncident = createServerFn({ method: "POST" })
|
|
| 82 |
await supabase.from("incidents").update({ status: "analyzing", error: null }).eq("id", data.incidentId);
|
| 83 |
|
| 84 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
const userContent = `INCIDENT TITLE: ${incident.title}\nSOURCE TYPE: ${incident.source_type}\nFILE: ${incident.file_name ?? "(none)"}\n\n--- RAW INPUT ---\n${incident.raw_text ?? "(no text content provided)"}`;
|
| 86 |
|
| 87 |
const requestBody = JSON.stringify({
|
|
@@ -89,6 +103,7 @@ export const analyzeIncident = createServerFn({ method: "POST" })
|
|
| 89 |
messages: [
|
| 90 |
{ role: "system", content: SYSTEM_PROMPT },
|
| 91 |
{ role: "system", content: AV_KNOWLEDGE_BASE },
|
|
|
|
| 92 |
{ role: "user", content: userContent },
|
| 93 |
],
|
| 94 |
tools: [analysisTool],
|
|
|
|
| 82 |
await supabase.from("incidents").update({ status: "analyzing", error: null }).eq("id", data.incidentId);
|
| 83 |
|
| 84 |
try {
|
| 85 |
+
// Pull the user's recent self-improvement learnings (Self-Improving Agent skill)
|
| 86 |
+
const { data: learnings } = await supabase
|
| 87 |
+
.from("qwen_learnings")
|
| 88 |
+
.select("category, content, context")
|
| 89 |
+
.eq("user_id", context.userId)
|
| 90 |
+
.order("created_at", { ascending: false })
|
| 91 |
+
.limit(20);
|
| 92 |
+
|
| 93 |
+
const learningsBlock = learnings && learnings.length
|
| 94 |
+
? `PRIOR LEARNINGS (operator corrections, insights, past errors — apply these going forward):\n${learnings
|
| 95 |
+
.map((l: any, i: number) => `${i + 1}. [${l.category}] ${l.content}${l.context ? ` (context: ${l.context})` : ""}`)
|
| 96 |
+
.join("\n")}`
|
| 97 |
+
: "PRIOR LEARNINGS: (none yet)";
|
| 98 |
+
|
| 99 |
const userContent = `INCIDENT TITLE: ${incident.title}\nSOURCE TYPE: ${incident.source_type}\nFILE: ${incident.file_name ?? "(none)"}\n\n--- RAW INPUT ---\n${incident.raw_text ?? "(no text content provided)"}`;
|
| 100 |
|
| 101 |
const requestBody = JSON.stringify({
|
|
|
|
| 103 |
messages: [
|
| 104 |
{ role: "system", content: SYSTEM_PROMPT },
|
| 105 |
{ role: "system", content: AV_KNOWLEDGE_BASE },
|
| 106 |
+
{ role: "system", content: learningsBlock },
|
| 107 |
{ role: "user", content: userContent },
|
| 108 |
],
|
| 109 |
tools: [analysisTool],
|