Skip to content

Commit 9192ffa

Browse files
committed
More optimisations for singul auto-test mapping
1 parent 1eb3aee commit 9192ffa

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

ai.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,11 +1711,26 @@ func AutofixAppLabels(app WorkflowApp, label string, keys []string) (WorkflowApp
17111711
if cacheGeterr != nil {
17121712
systemMessage := `Your goal is to find the most correct action for a specific label from the actions. You have to pick the most likely action. Synonyms are accepted, and you should be very critical to not make mistakes. A synonym example can be something like: case = alert = ticket = issue = task, or message = chat = communication. Be extra careful of not confusing LIST and GET operations, based on the user query, respond with the most likely action name. If it exists, return {"success": true, "action": "<action>"} where <action> is replaced with the action found. If it does not exist, Last case scenario is return {"success": false, "action": ""}. Output as JSON with JUST the action name."`
17131713

1714+
userMessage := fmt.Sprintf("Out of the following actions, which action matches '%s'?\n", label)
1715+
1716+
// Special handler for validation / testing to auto-map an action for an app
17141717
if label == "app_validation" || label == "test" || label == "test_api" {
1715-
systemMessage = fmt.Sprintf(`Your goal is to find the most correct action for TESTING an API. You have to pick the most likely action. Synonyms are accepted. A synonym example can be something like: case = alert = ticket = issue = task, or message = chat = communication. E.g. for ITSM it should be to list tickets. For email, to list emails. For EDR, to list alerts etc. Find a simple API. The current app is '%s'. Our goal is to get a 200 OK or similar. If it exists, return {"success": true, "action": "<action>"} where <action> is replaced with the action found. If it does not exist, Last case scenario is return {"success": false, "action": ""}. Output as JSON, with JUST the action name.`, app.Name)
1716-
}
1718+
systemMessage = fmt.Sprintf(`Your goal is to select one action from the list that is most likely to return a 200 OK or similar response for testing an API. The API name is %s with the category %s.
17171719
1718-
userMessage := fmt.Sprintf("Out of the following actions, which action matches '%s'?\n", label)
1720+
Rules:
1721+
1. Prefer list or collection endpoints that return multiple items (e.g., emails, tickets, alerts, messages, files, resources).
1722+
2. If no list/collection endpoint exists, fallback to a single-object retrieval (e.g., get user).
1723+
3. Synonyms are allowed (e.g., message = email = communication, case = ticket = issue = task).
1724+
4. Ignore authentication/permission details; assume the call works.
1725+
5. Do not pick endpoints that create, delete, or modify data.
1726+
1727+
Output only one JSON object:
1728+
* If a valid action exists: {"success": true, "action": "<action>"}
1729+
* If none exists: {"success": false, "action": ""}
1730+
1731+
Do not add explanations, comments, or extra formatting. Only return valid JSON.`, app.Name, strings.Join(app.Categories, ", "))
1732+
userMessage = ""
1733+
}
17191734

17201735
//changedNames := map[string]string{}
17211736
parsedLabel := strings.ToLower(strings.ReplaceAll(label, " ", "_"))
@@ -1827,7 +1842,7 @@ func AutofixAppLabels(app WorkflowApp, label string, keys []string) (WorkflowApp
18271842
Content: userMessage,
18281843
},
18291844
},
1830-
MaxTokens: maxTokens,
1845+
MaxCompletionTokens: maxTokens,
18311846
Temperature: 0,
18321847
ReasoningEffort: "low",
18331848
}

blobs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ func GetDefaultWorkflowByType(workflow Workflow, orgId string, categoryAction Ca
476476
// This is done specifically for Singul ingests
477477
positionAddition := float64(250)
478478

479-
log.Printf("ACTIONS: %d, TRIGGERS: %d, APPNAMES: %d, FIRSTACTION: %s, TRIGGER: %s", len(workflow.Actions), len(workflow.Triggers), len(appNames), workflow.Actions[0].AppName, workflow.Triggers[0].TriggerType)
480-
os.Exit(3)
479+
//log.Printf("ACTIONS: %d, TRIGGERS: %d, APPNAMES: %d, FIRSTACTION: %s, TRIGGER: %s", len(workflow.Actions), len(workflow.Triggers), len(appNames), workflow.Actions[0].AppName, workflow.Triggers[0].TriggerType)
480+
//os.Exit(3)
481481
if len(workflow.Actions) == 1 && (workflow.Actions[0].AppName == "Singul" || workflow.Actions[0].AppID == "integration") && len(appNames) > 0 && len(workflow.Triggers) == 1 && workflow.Triggers[0].TriggerType == "SCHEDULE" {
482482

483483
actionTemplate := workflow.Actions[0]

0 commit comments

Comments
 (0)