Commit 36de8a7f by haojie

1

parent f9baf31e
...@@ -38,23 +38,23 @@ public function validateSubmitData(array $data = []) ...@@ -38,23 +38,23 @@ public function validateSubmitData(array $data = [])
$promptNum = $data['prompt_num'] ?? ''; $promptNum = $data['prompt_num'] ?? '';
if (empty($type) || empty($prompt)) { if (empty($type) || empty($prompt)) {
throw new UserException('任务类型不能为空'); throw new UserException(1, '任务类型不能为空');
} }
# 生成指令数量只能在1-10之间 # 生成指令数量只能在1-10之间
if ($promptNum < 1 || $promptNum > 10) { if ($promptNum < 1 || $promptNum > 10) {
throw new UserException('生成指令数量只能在1-10之间'); throw new UserException(1, '生成指令数量只能在1-10之间');
} }
# 判断类型 # 判断类型
if ($type == self::TYPE_IMG_TO_IMG) { if ($type == self::TYPE_IMG_TO_IMG) {
# 图片转图片 # 图片转图片
if (!count($promptImg)) { if (!count($promptImg)) {
throw new UserException('图片不能为空'); throw new UserException(1, '图片不能为空');
} }
} elseif ($type == self::TYPE_TEXT_TO_IMG) { } elseif ($type == self::TYPE_TEXT_TO_IMG) {
# 文字转图片 # 文字转图片
} else { } else {
throw new UserException('任务类型错误'); throw new UserException(1, '任务类型错误');
} }
} }
...@@ -206,7 +206,7 @@ public function stableCallback(array $data = []) ...@@ -206,7 +206,7 @@ public function stableCallback(array $data = [])
$message = $data['message'] ?? ''; $message = $data['message'] ?? '';
$status = $data['status'] ?? false; $status = $data['status'] ?? false;
if (empty($task_id) || empty($prompt_id)) { if (empty($task_id) || empty($prompt_id)) {
throw new UserException('缺少字段'); throw new UserException(1, '参数错误');
} }
if (!$status) { if (!$status) {
# 任务失败 # 任务失败
...@@ -236,7 +236,7 @@ public function stableCallback(array $data = []) ...@@ -236,7 +236,7 @@ public function stableCallback(array $data = [])
*/ */
public function setRedis($task_id, $data = []) public function setRedis($task_id, $data = [])
{ {
$data['callback'] = config('common.callback'); $data['callback'] = config('common . callback');
$data['task_id'] = $task_id; $data['task_id'] = $task_id;
Redis::rpush('gpt_text_prompt', json_encode($data)); Redis::rpush('gpt_text_prompt', json_encode($data));
} }
...@@ -259,11 +259,11 @@ public function gpt_callback($data = []) ...@@ -259,11 +259,11 @@ public function gpt_callback($data = [])
$result_img = $credentials['result_img'] ?? ''; $result_img = $credentials['result_img'] ?? '';
# 判断必须字段 # 判断必须字段
if (empty($type) || empty($prompt) || empty($user_id) || empty($task_id)) { if (empty($type) || empty($prompt) || empty($user_id) || empty($task_id)) {
throw new UserException('gpt_callback--$user_id,$task_id,$prompt,$type参数错误'); throw new UserException(1, 'gpt_callback--$user_id,$task_id,$prompt,$type参数错误');
} }
# 判断$data是否为数组 # 判断$data是否为数组
if (!is_array($prompt)) { if (!is_array($prompt)) {
throw new UserException('gpt_callback--$prompt参数错误'); throw new UserException(1, 'gpt_callback--$prompt参数错误');
} }
# 循环 # 循环
foreach ($prompt as $item) { foreach ($prompt as $item) {
...@@ -274,8 +274,8 @@ public function gpt_callback($data = []) ...@@ -274,8 +274,8 @@ public function gpt_callback($data = [])
'prompt_img' => $prompt_img, 'prompt_img' => $prompt_img,
'result_img' => $result_img, 'result_img' => $result_img,
'type' => $type, 'type' => $type,
'callback' => config('common.prompt_callback'), 'callback' => config('common . prompt_callback'),
'policy' => config('common.policy_callback'), 'policy' => config('common . policy_callback'),
]; ];
$prompt_id = promptTask::query()->create($list)->id; $prompt_id = promptTask::query()->create($list)->id;
$list['prompt_id'] = $prompt_id; $list['prompt_id'] = $prompt_id;
...@@ -300,7 +300,7 @@ public function prompt_callback($data = []) ...@@ -300,7 +300,7 @@ public function prompt_callback($data = [])
$message = $credentials['message'] ?? ''; $message = $credentials['message'] ?? '';
# 判断必须字段 # 判断必须字段
if (empty($user_id) || empty($task_id) || empty($result_img) || empty($prompt_id)) { if (empty($user_id) || empty($task_id) || empty($result_img) || empty($prompt_id)) {
throw new UserException('指令回调缺少参数'); throw new UserException(1, '指令回调缺少参数');
} }
# 如果存在message,则提交失败信息 # 如果存在message,则提交失败信息
if ($message) { if ($message) {
...@@ -321,7 +321,7 @@ public function prompt_callback($data = []) ...@@ -321,7 +321,7 @@ public function prompt_callback($data = [])
'task_id' => $task_id, 'task_id' => $task_id,
'prompt_id' => $prompt_id, 'prompt_id' => $prompt_id,
'result_img' => $result_img, 'result_img' => $result_img,
'callback' => config('common.img_download_callback'), 'callback' => config('common . img_download_callback'),
]; ];
# redis队列插入任务--转存图片 # redis队列插入任务--转存图片
Redis::rpush('discord_img_download', json_encode($list)); Redis::rpush('discord_img_download', json_encode($list));
...@@ -341,7 +341,7 @@ public function img_download_callback($data = []) ...@@ -341,7 +341,7 @@ public function img_download_callback($data = [])
$result_img = $credentials['result_img'] ?? ''; $result_img = $credentials['result_img'] ?? '';
# 判断必须字段 # 判断必须字段
if (empty($prompt_id)) { if (empty($prompt_id)) {
throw new UserException('参数错误'); throw new UserException(1, '参数错误');
} }
# 获取任务 # 获取任务
$task = PromptTask::query()->where('id', $prompt_id)->first(); $task = PromptTask::query()->where('id', $prompt_id)->first();
...@@ -374,7 +374,7 @@ public function task_callback($user_id, $data = []) ...@@ -374,7 +374,7 @@ public function task_callback($user_id, $data = [])
$task_id = $credentials['task_id']; $task_id = $credentials['task_id'];
# 判断必须字段 # 判断必须字段
if (empty($task_id)) { if (empty($task_id)) {
throw new UserException('缺少id'); throw new UserException(1, '缺少id');
} }
# 查询所有 # 查询所有
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment