mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-06-09 14:45:26 +00:00
修复 lint,忽略F405
This commit is contained in:
parent
0b6ac9f73e
commit
a5e72c6946
@ -1,4 +1,5 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@ -21,9 +22,10 @@ from nonebot.rule import to_me
|
|||||||
from nonebot.typing import T_State
|
from nonebot.typing import T_State
|
||||||
from nonebot_plugin_alconna import MsgTarget, UniMessage, UniMsg, on_alconna
|
from nonebot_plugin_alconna import MsgTarget, UniMessage, UniMsg, on_alconna
|
||||||
|
|
||||||
from .constants import INTRODUCTION, OPENAI_NEW_MODELS, SUPPORT_IMAGE_MODELS
|
from .config import config
|
||||||
|
from .constants import INTRODUCTION, SUPPORT_IMAGE_MODELS
|
||||||
from .hooks import *
|
from .hooks import *
|
||||||
from .instances import *
|
from .instances import client, context, model_name, target_list, tools
|
||||||
from .metadata import metadata
|
from .metadata import metadata
|
||||||
from .plugin.func_call.caller import get_function_calls
|
from .plugin.func_call.caller import get_function_calls
|
||||||
from .plugin.func_call.models import SessionContext
|
from .plugin.func_call.models import SessionContext
|
||||||
@ -257,7 +259,6 @@ async def marsho(
|
|||||||
model_name.lower()
|
model_name.lower()
|
||||||
in SUPPORT_IMAGE_MODELS + config.marshoai_additional_image_models
|
in SUPPORT_IMAGE_MODELS + config.marshoai_additional_image_models
|
||||||
)
|
)
|
||||||
is_openai_new_model = model_name.lower() in OPENAI_NEW_MODELS
|
|
||||||
usermsg = [] if is_support_image_model else ""
|
usermsg = [] if is_support_image_model else ""
|
||||||
for i in text: # type: ignore
|
for i in text: # type: ignore
|
||||||
if i.type == "text":
|
if i.type == "text":
|
||||||
@ -302,7 +303,7 @@ async def marsho(
|
|||||||
choice = response.choices[0]
|
choice = response.choices[0]
|
||||||
# Sprint(choice)
|
# Sprint(choice)
|
||||||
# 当tool_calls非空时,将finish_reason设置为TOOL_CALLS
|
# 当tool_calls非空时,将finish_reason设置为TOOL_CALLS
|
||||||
if choice.message.tool_calls != None and config.marshoai_fix_toolcalls:
|
if choice.message.tool_calls is not None and config.marshoai_fix_toolcalls:
|
||||||
choice.finish_reason = "tool_calls"
|
choice.finish_reason = "tool_calls"
|
||||||
logger.info(f"完成原因:{choice.finish_reason}")
|
logger.info(f"完成原因:{choice.finish_reason}")
|
||||||
if choice.finish_reason == CompletionsFinishReason.STOPPED:
|
if choice.finish_reason == CompletionsFinishReason.STOPPED:
|
||||||
@ -342,7 +343,7 @@ async def marsho(
|
|||||||
# function call
|
# function call
|
||||||
# 需要获取额外信息,调用函数工具
|
# 需要获取额外信息,调用函数工具
|
||||||
tool_msg = []
|
tool_msg = []
|
||||||
while choice.message.tool_calls != None:
|
while choice.message.tool_calls is not None:
|
||||||
# await UniMessage(str(response)).send()
|
# await UniMessage(str(response)).send()
|
||||||
tool_calls = choice.message.tool_calls
|
tool_calls = choice.message.tool_calls
|
||||||
# try:
|
# try:
|
||||||
@ -411,7 +412,7 @@ async def marsho(
|
|||||||
)
|
)
|
||||||
choice = response.choices[0]
|
choice = response.choices[0]
|
||||||
# 当tool_calls非空时,将finish_reason设置为TOOL_CALLS
|
# 当tool_calls非空时,将finish_reason设置为TOOL_CALLS
|
||||||
if choice.message.tool_calls != None:
|
if choice.message.tool_calls is not None:
|
||||||
choice.finish_reason = CompletionsFinishReason.TOOL_CALLS
|
choice.finish_reason = CompletionsFinishReason.TOOL_CALLS
|
||||||
if choice.finish_reason == CompletionsFinishReason.STOPPED:
|
if choice.finish_reason == CompletionsFinishReason.STOPPED:
|
||||||
|
|
||||||
|
@ -81,4 +81,4 @@ test = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
ignore = ["E402"]
|
ignore = ["E402", "F405"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user