Made decision detection more robust.

This commit is contained in:
Steve White 2025-01-25 15:18:11 -06:00
parent a28288259f
commit 80d60acf64
1 changed files with 10 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"strings"
"time" "time"
) )
@ -184,7 +185,15 @@ Abstract: %s`, criteria, paper.Title, paper.Abstract)
return nil, fmt.Errorf("invalid response format") return nil, fmt.Errorf("invalid response format")
} }
decision := string(bytes.TrimSpace(lines[0])) decisionParts := bytes.SplitN(lines[0], []byte(":"), 2)
if len(decisionParts) != 2 {
return nil, fmt.Errorf("invalid decision format, expected 'DECISION: [VALUE]'")
}
decision := strings.ToUpper(string(bytes.TrimSpace(decisionParts[1])))
if decision != "ACCEPT" && decision != "REJECT" {
return nil, fmt.Errorf("invalid decision value: %s", decision)
}
explanation := string(bytes.TrimSpace(bytes.Join(lines[1:], []byte("\n")))) explanation := string(bytes.TrimSpace(bytes.Join(lines[1:], []byte("\n"))))
return &decisionResult{ return &decisionResult{