Skip to content

Commit 519e272

Browse files
committed
Multiple singul map and print fixes
1 parent 4434618 commit 519e272

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

ai.go

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,16 @@ func FixContentOutput(contentOutput string) string {
13571357
log.Printf("[WARNING] Failed to marshal indent tmpMap in FixContentOutput (1): %s", err)
13581358
}
13591359
} else {
1360-
log.Printf("[WARNING] Failed to unmarshal tmpMap in FixContentOutput (2): %s => %s", string(contentOutput), err)
1360+
arrayMap := []interface{}{}
1361+
newErr := json.Unmarshal([]byte(contentOutput), &arrayMap)
1362+
if newErr != nil {
1363+
log.Printf("[WARNING] Failed to unmarshal tmpMap in FixContentOutput (2) - both map & interface list: %s => %s => %s", string(contentOutput), err, newErr)
1364+
} else {
1365+
marshalled, err := json.MarshalIndent(arrayMap, "", " ")
1366+
if err == nil {
1367+
contentOutput = string(marshalled)
1368+
}
1369+
}
13611370
}
13621371

13631372
return contentOutput
@@ -6629,7 +6638,7 @@ func HandleAiAgentExecutionStart(execution WorkflowExecution, startNode Action,
66296638
ctx := context.Background()
66306639

66316640
// Create the OpenAI body struct
6632-
systemMessage := `INTRODUCTION:
6641+
systemMessage := `INTRODUCTION
66336642
You are a general AI agent which makes decisions based on user input. You should output a list of decisions based on the same input. Available actions within categories you can choose from are below. Only use the built-in actions 'answer' (ai analysis) or 'ask' (human analysis) if it fits 100%, is not the last action AND it can't be done with an API. These actions are a last resort. Use Markdown with focus on human readability. Do NOT ask about networking or authentication unless explicitly specified.
66346643
66356644
END INTRODUCTION
@@ -6642,6 +6651,7 @@ SINGUL ACTIONS:
66426651
openaiAllowedApps := []string{"openai"}
66436652
runOpenaiRequest := false
66446653
appname := ""
6654+
inputActionString := ""
66456655

66466656
decidedApps := []string{}
66476657

@@ -6663,14 +6673,18 @@ SINGUL ACTIONS:
66636673
}
66646674

66656675
if param.Name == "action" {
6676+
inputActionString = param.Value
66666677
for _, actionStr := range strings.Split(param.Value, ",") {
66676678
actionStr = strings.ToLower(strings.TrimSpace(actionStr))
6668-
log.Printf("STR: '%s'", actionStr)
66696679
if actionStr == "" || actionStr == "nothing" {
66706680
continue
66716681
}
66726682

6673-
log.Printf("ACTIONSTR: '%s'", actionStr)
6683+
6684+
if debug {
6685+
log.Printf("ACTIONSTR: '%s'", actionStr)
6686+
}
6687+
66746688
if strings.HasPrefix(actionStr, "app:") {
66756689

66766690
trimmedActionStr := strings.TrimPrefix(actionStr, "app:")
@@ -6695,8 +6709,10 @@ SINGUL ACTIONS:
66956709
}
66966710
}
66976711

6698-
log.Printf("PARAM: %s", param.Value)
6699-
log.Printf("Systemmessage: %s", systemMessage)
6712+
if debug {
6713+
log.Printf("PARAM: %s", param.Value)
6714+
log.Printf("Systemmessage: %s", systemMessage)
6715+
}
67006716

67016717
systemMessage += "\n\n"
67026718
}
@@ -7013,7 +7029,7 @@ END STANDALONE ACTIONS
70137029
---
70147030
DECISION FORMATTING
70157031
7016-
Available categories: %s. If you are unsure about a decision, always ask for user input. The output should be an ordered JSON list in the format [{"i": 0, "category": "singul", "action": "action_name", "tool": "<tool name>", "confidence": 0.95, "runs": "1", "reason": "Short reason why", "fields": [{"key": "body", "value": "$action_name"}] WITHOUT newlines. The reason should be concise and understandable to a user, and should not include unnecessary details.
7032+
Available categories: %s. If you are unsure about a decision, always ask for user input. The output should be an ordered JSON list in the format [{"i": 0, "category": "singul", "action": "action_name", "tool": "tool name", "confidence": 0.95, "runs": "1", "reason": "Short reason why", "fields": [{"key": "body", "value": "$action_name"}] WITHOUT newlines. The reason should be concise and understandable to a user, and should not include unnecessary details.
70177033
70187034
END DECISION FORMATTING
70197035
---
@@ -7030,7 +7046,7 @@ RULES:
70307046
* Fields is an array based on key: value pairs. Don't add unnecessary fields. If using 'ask', the key is 'question' and the value is the question to ask. If using 'answer', the key is 'output' and the value is what to answer.
70317047
* NEVER skip executing an action, even if some details are unclear. Fill missing fields only with safe defaults, but still execute.
70327048
* NEVER ask the user for clarification, confirmations, or extra details unless it is absolutely unavoidable.
7033-
* If realtime data is required, ALWAYS use an Singul APIs to get it.
7049+
* If realtime data is required, ALWAYS use APIs to get it.
70347050
* ALWAYS output the same language as the original question.
70357051
* ALWAYS format questions using Markdown formatting, with a focus on human readability.
70367052
@@ -7041,9 +7057,9 @@ RULES:
70417057
* NEVER ask for usernames, API keys, passwords, or authentication information.
70427058
* NEVER ask for confirmation before performing an action.
70437059
* NEVER skip execution because of minor missing details—fill them with reasonable defaults (e.g., default units or formats) and proceed.
7060+
* If API action, ALWAYS include the url, method, headers and body when using an API action
70447061
* Do NOT add unnecessary fields; only include fields required for the action.
7045-
* Fields can reference previous action outputs using {{action_name}}. Example: {"body": "{{previous_action.field}}"}.
7046-
* If questions are absolutely required, combine all into one "ask" action with multiple "question" fields. Do NOT create multiple separate decisions.
7062+
* If questions are absolutely required, combine all into one "ask" action with multiple "question" fields. Do NOT create multiple separate ones.
70477063
* Retry actions if the result was irrelevant. After three retries of a failed decision, add the finish decision.
70487064
* If any decision has failed, add the finish decision with details about the failure.
70497065
* If a formatting is specified for the output, use it exactly how explained for the finish decision.
@@ -7471,6 +7487,8 @@ FINALISING:
74717487
StartedAt: time.Now().Unix(),
74727488

74737489
Memory: memorizationEngine,
7490+
7491+
AllowedActions: strings.Split(inputActionString, ","),
74747492
}
74757493

74767494
if len(errorMessage) > 0 {

structs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4585,8 +4585,9 @@ type AgentOutput struct {
45854585
NodeId string `json:"node_id,omitempty" datastore:"node_id"`
45864586
Memory string `json:"memory,omitempty" datastore:"memory"`
45874587
Input string `json:"input" datastore:"input"`
4588-
Output string `json:"output,omitempty" datastore:"output"`
45894588
OriginalInput string `json:"original_input,omitempty" datastore:"original_input"`
4589+
AllowedActions []string `json:"allowed_actions,omitempty" datastore:"allowed_actions"`
4590+
Output string `json:"output,omitempty" datastore:"output"`
45904591
}
45914592

45924593
type HTTPWrapper struct {

0 commit comments

Comments
 (0)