Commit 94019363 by haojie

1

parent 2a936aba
......@@ -70,6 +70,13 @@ public function submit(int $user_id = 0, array $data = [])
$data['prompt'] = str_replace('\n', '', $data['prompt']);
$task = $this->createTask($user_id, $data);
$promptTask = $this->createPromptTask($user_id, $task->id, $data);
$list = [
'type' => (string)($data['type'] ?? ''),
'prompt' => (string)($data['prompt'] ?? ''),
'prompt_img' => json_encode($data['prompt_img'] ?? []),
'user_id' => $user_id,
'prompt_num' => self::GPT_prompt_num,
];
$list['prompt_id'] = $promptTask->id;
# 插入redis,这是自动化的任务
Redis::rpush('midjourney_prompt', json_encode($list));
......@@ -152,6 +159,30 @@ public function apiSubmit(int $userId = 0, array $data = [])
];
}
/**
* stable 提交任务=-------
*/
public function stableSubmit(int $userId = 0, array $data = [])
{
$this->validateSubmitData($data);
$data['prompt'] = str_replace('\n', '', $data['prompt']);
$task = $this->createTask($userId, $data);
$promptTask = $this->createPromptTask($userId, $task->id, $data);
$sendData = [
'prompt' => $task->prompt,
'prompt_img' => $task->prompt_img,
'prompt_id' => $promptTask->id,
'task_id' => $task->id,
'type' => $task->type,
];
# 提交redis
Redis::rpush('stable_task', json_encode($sendData));
return [
'task_id' => $task->id,
'prompt_num' => $task->prompt_num
];
}
/**
* redis队列插入--这是gpt生成指令的任务
......@@ -339,24 +370,13 @@ public function create_split_img_task(int $user_id = 0, $data = [])
$prompt->update([
'cut_id' => $cut_id,
]);
if ((int)$type === self::TASK_TYPE_AUTO) {
# 添加redis任务
$list = [
'prompt_id' => $prompt_id,
'result_img' => $prompt->result_img,
'cut_id' => $cut_id,
'callback' => config('common.split_img_callback'),
];
Redis::rpush('discord_img_split', json_encode($list));
} else {
$downloadData = [
'url' => $prompt->result_img,
'name' => Str::uuid()->toString(),
'index' => $cut_id,
'prompt_id' => $prompt_id,
];
dispatch(new DownloadImageJob($downloadData));
}
$downloadData = [
'url' => $prompt->result_img,
'name' => Str::uuid()->toString(),
'index' => $cut_id,
'prompt_id' => $prompt_id,
];
dispatch(new DownloadImageJob($downloadData));
return [
'prompt_id' => $prompt_id,
];
......
......@@ -49,6 +49,8 @@
Route::post('submit', 'TaskController@SubmitTask');
// Api 提交任务
Route::post('api-submit', 'TaskController@apiSubmit');
// stable 提交任务
Route::post('stable-submit', 'TaskController@stableSubmit');
# 轮询请求任务回调
Route::get('task/callback', 'TaskController@task_callback');
# 创建切割图片任务
......
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