Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 17 additions & 50 deletions ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import (
var standalone bool

// var model = "gpt-5-mini"
//var model = "gpt-5-mini"
var model = "gpt-5.4-nano"
var model = "gpt-5-mini"
//var model = "gpt-5.4-nano"
//var model = "gpt-5.2-codex"

var fallbackModel = ""
Expand Down Expand Up @@ -1541,53 +1541,20 @@ func FixJSONNewlines(input string) string {
}

func FixContentOutput(contentOutput string) string {
if strings.Contains(contentOutput, "```json") {
// Handle ```json
start := strings.Index(contentOutput, "```json")
end := strings.Index(contentOutput, "```")
if start != -1 {
end = strings.Index(contentOutput[start+7:], "```")

// Shift it so the index is at the correct place
end = end + start + 7
}

if start != -1 && end != -1 {
newend := end + 7
newstart := start + 7

log.Printf("[INFO] Found ``` in content. Start: %d, end: %d", start, end)

if newend > len(contentOutput) {
newend = end
}

if newend > len(contentOutput) {
newend = len(contentOutput)
}

if newstart > len(contentOutput) {
newstart = start
}

if newstart > len(contentOutput) {
newstart = len(contentOutput)
}

contentOutput = contentOutput[start+7 : newend]
}
}

if strings.Contains(contentOutput, "```") {
start := strings.Index(contentOutput, "```")
end := strings.Index(contentOutput[start+3:], "```")
if start != -1 {
end = strings.Index(contentOutput[start+3:], "```")
end = end + start + 3
// Safely extract content from ```json or ``` blocks
if start := strings.Index(contentOutput, "```json"); start != -1 {
start += 7 // skip ```json
if end := strings.Index(contentOutput[start:], "```"); end != -1 {
contentOutput = contentOutput[start : start+end]
} else {
contentOutput = contentOutput[start:] // Unmatched, take the rest
}

if start != -1 && end != -1 {
contentOutput = contentOutput[start+3 : end+3]
} else if start := strings.Index(contentOutput, "```"); start != -1 {
start += 3 // skip ```
if end := strings.Index(contentOutput[start:], "```"); end != -1 {
contentOutput = contentOutput[start : start+end]
} else {
contentOutput = contentOutput[start:] // Unmatched, take the rest
}
}

Expand Down Expand Up @@ -8749,7 +8716,7 @@ data_filter:
}

// Maps OpenAI -> Result struct so we can handle it
resultMapping := ActionResult{}
resultMapping = ActionResult{}
err = json.Unmarshal(body, &resultMapping)
if err != nil {
log.Printf("[ERROR] AI Agent (2): Failed unmarshalling response into decisions. Response from sending AI Agent request to %s: %d - '%s'. Err: %s", fullUrl, llmStatusCode, string(body), err)
Expand Down Expand Up @@ -8872,7 +8839,7 @@ data_filter:
}

// Parse the outputMap.Result to OpenAI response
choicesString := ""
// choicesString = ""
bodyMap, ok := outputMap.Body.(map[string]interface{})
if !ok {
log.Printf("[ERROR][%s] AI Agent: Failed to convert body to MAP in AI Agent response. Raw response: %s", execution.ExecutionId, string(resultMapping.Result))
Expand Down
4 changes: 2 additions & 2 deletions blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
func IsShuffleApp(app WorkflowApp) bool {
parsedAppname := strings.ReplaceAll(strings.ToLower(app.Name), " ", "_")

skipAuthAppnames := []string{"openai", "shuffle_datastore", "shuffle_workflows", "shuffle_detection", "shuffle_sensors", "shuffle_monitors", "shuffle_host_monitors", "shuffles_app_management"}
skipAuthAppIds := []string{"5d19dd82517870c68d40cacad9b5ca91", "b82668d868f6dc7ac1dc14caa92c674b", "b598b078fd5c531699fca803c172ce72", "afda48b8d1f7dc7ac3caae87b2c072e9", "7f12d725c356677d28db042170444448", "48a954b9440b3913b8a2620e57b94a75", "605e31b19889e38f179fab112297eb42"}
skipAuthAppnames := []string{"openai", "shuffle_datastore", "shuffle_workflows", "shuffle_detection", "shuffle_sensors", "shuffle_monitors", "shuffle_host_monitors", "shuffle_apps"}
skipAuthAppIds := []string{"5d19dd82517870c68d40cacad9b5ca91", "b82668d868f6dc7ac1dc14caa92c674b", "b598b078fd5c531699fca803c172ce72", "afda48b8d1f7dc7ac3caae87b2c072e9", "7f12d725c356677d28db042170444448", "48a954b9440b3913b8a2620e57b94a75", "7db43ccd25261967b095cfbd467a75cc"}

isShuffleApp := false
if project.Environment == "cloud" && len(app.ID) > 0 {
Expand Down
Loading
Loading