* quit audit on exception.

This commit is contained in:
liwenrui
2023-10-10 11:03:51 +08:00
parent eeb77c6e88
commit d2380703b6
+10 -1
View File
@@ -518,14 +518,23 @@ class ai extends control
if(empty($location)) return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->ai->execute->failFormat, $this->lang->ai->execute->failReasons['noTargetForm'])));
if(!empty($stop)) return header("location: $location", true, 302);
/* Execute prompt and catch exceptions. */
try
{
$response = $this->ai->executePrompt($prompt, $object);
}
catch(AIResponseException $e)
{
return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->ai->execute->failFormat, $e->getMessage())));
$output = array('result' => 'fail', 'message' => sprintf($this->lang->ai->execute->failFormat, $e->getMessage()));
/* Audition shall quit on such exception. */
if(isset($_SESSION['auditPrompt']) && time() - $_SESSION['auditPrompt']['time'] < 10 * 60)
{
$output['locate'] = $this->inlink('promptAudit', "promptID=$promptId&objectId=$objectId&exit=true");
}
return $this->send($output);
}
if(is_int($response)) return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->ai->execute->failFormat, $this->lang->ai->execute->executeErrors["$response"]) . (empty($this->ai->errors) ? '' : implode(', ', $this->ai->errors))));
if(empty($response)) return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->ai->execute->failFormat, $this->lang->ai->execute->failReasons['noResponse'])));