Made decision detection more robust.
This commit is contained in:
parent
a28288259f
commit
80d60acf64
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -184,7 +185,15 @@ Abstract: %s`, criteria, paper.Title, paper.Abstract)
|
|||
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"))))
|
||||
|
||||
return &decisionResult{
|
||||
|
|
Loading…
Reference in New Issue