Browse Source

fix: fast mode and relax mode checkout

master
zhayujie 1 year ago
parent
commit
de26dc0597
2 changed files with 8 additions and 7 deletions
  1. +1
    -1
      plugins/linkai/linkai.py
  2. +7
    -6
      plugins/linkai/midjourney.py

+ 1
- 1
plugins/linkai/linkai.py View File

@@ -66,7 +66,7 @@ class LinkAI(Plugin):
if not context.kwargs.get("isgroup"): if not context.kwargs.get("isgroup"):
_set_reply_text("该指令需在群聊中使用", e_context, level=ReplyType.ERROR) _set_reply_text("该指令需在群聊中使用", e_context, level=ReplyType.ERROR)
return return
if e_context["context"]["session_id"] not in global_config["admin_users"]:
if context.kwargs.get("msg").actual_user_id not in global_config["admin_users"]:
_set_reply_text("需要管理员权限执行", e_context, level=ReplyType.ERROR) _set_reply_text("需要管理员权限执行", e_context, level=ReplyType.ERROR)
return return
app_code = cmd[2] app_code = cmd[2]


+ 7
- 6
plugins/linkai/midjourney.py View File

@@ -149,7 +149,7 @@ class MJBot:
if res.get("code") == 200: if res.get("code") == 200:
task_id = res.get("data").get("taskId") task_id = res.get("data").get("taskId")
real_prompt = res.get("data").get("realPrompt") real_prompt = res.get("data").get("realPrompt")
if mode == TaskMode.RELAX.name:
if mode == TaskMode.RELAX.value:
time_str = "1~10分钟" time_str = "1~10分钟"
else: else:
time_str = "1~2分钟" time_str = "1~2分钟"
@@ -174,11 +174,12 @@ class MJBot:
logger.info(f"[MJ] image upscale, img_id={img_id}, index={index}") logger.info(f"[MJ] image upscale, img_id={img_id}, index={index}")
body = {"type": TaskType.UPSCALE.name, "imgId": img_id, "index": index} body = {"type": TaskType.UPSCALE.name, "imgId": img_id, "index": index}
res = requests.post(url=self.base_url + "/operate", json=body, headers=self.headers) res = requests.post(url=self.base_url + "/operate", json=body, headers=self.headers)
logger.debug(res)
if res.status_code == 200: if res.status_code == 200:
res = res.json() res = res.json()
logger.info(res)
if res.get("code") == 200: if res.get("code") == 200:
task_id = res.get("data").get("taskId") task_id = res.get("data").get("taskId")
logger.info(f"[MJ] image upscale processing, task_id={task_id}")
content = f"🔎图片正在放大中,请耐心等待" content = f"🔎图片正在放大中,请耐心等待"
reply = Reply(ReplyType.INFO, content) reply = Reply(ReplyType.INFO, content)
task = MJTask(id=task_id, status=Status.PENDING, user_id=user_id, task_type=TaskType.UPSCALE) task = MJTask(id=task_id, status=Status.PENDING, user_id=user_id, task_type=TaskType.UPSCALE)
@@ -274,7 +275,7 @@ class MJBot:
return False return False
task_count = len([t for t in self.tasks.values() if t.status == Status.PENDING]) task_count = len([t for t in self.tasks.values() if t.status == Status.PENDING])
if task_count >= self.config.get("max_tasks"): if task_count >= self.config.get("max_tasks"):
reply = Reply(ReplyType.INFO, "Midjourney服务的总任务数已达上限,请稍后再试")
reply = Reply(ReplyType.INFO, "Midjourney作图任务数已达上限,请稍后再试")
e_context["reply"] = reply e_context["reply"] = reply
e_context.action = EventAction.BREAK_PASS e_context.action = EventAction.BREAK_PASS
return False return False
@@ -282,9 +283,9 @@ class MJBot:


def _fetch_mode(self, prompt) -> str: def _fetch_mode(self, prompt) -> str:
mode = self.config.get("mode") mode = self.config.get("mode")
if "--relax" in prompt or mode == TaskMode.RELAX.name:
return TaskMode.RELAX.name
return TaskMode.FAST.name
if "--relax" in prompt or mode == TaskMode.RELAX.value:
return TaskMode.RELAX.value
return mode or TaskMode.RELAX.value


def _run_loop(self, loop: asyncio.BaseEventLoop): def _run_loop(self, loop: asyncio.BaseEventLoop):
""" """


Loading…
Cancel
Save