From cfdef0a14e6ee0280a1acb2038bcf02cff0b0903 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Mon, 2 Feb 2026 20:32:52 +0000
Subject: [PATCH 1/2] chore: auto update by pre-commit hooks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
updates:
- [github.com/psf/black-pre-commit-mirror: 25.12.0 → 26.1.0](https://github.com/psf/black-pre-commit-mirror/compare/25.12.0...26.1.0)
---
.pre-commit-config.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 508a5f6..a8c03d3 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -21,7 +21,7 @@ repos:
additional_dependencies: ["types-PyYAML", "types-pytz", "azure-ai-inference", "dashscope", "google-genai", "ollama"]
- repo: https://github.com/psf/black-pre-commit-mirror
- rev: 25.12.0
+ rev: 26.1.0
hooks:
- id: black
args: ["--config=./pyproject.toml"]
From c1d5e4498e43c5f172b1e2a7eaed99fee5720f47 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Mon, 2 Feb 2026 20:33:23 +0000
Subject: [PATCH 2/2] style: auto fix by pre-commit hooks
---
bot.py | 2 +-
muicebot/llm/embeddings/gemini.py | 2 +-
muicebot/llm/providers/dashscope.py | 6 +++---
muicebot/llm/providers/gemini.py | 16 ++++++++--------
muicebot/llm/providers/ollama.py | 4 ++--
muicebot/llm/providers/openai.py | 28 +++++++++++++---------------
muicebot/onebot.py | 8 +++-----
muicebot/plugin/func_call/caller.py | 2 +-
muicebot/plugin/loader.py | 2 +-
9 files changed, 33 insertions(+), 37 deletions(-)
diff --git a/bot.py b/bot.py
index c173e8a..b4fbdb5 100644
--- a/bot.py
+++ b/bot.py
@@ -12,7 +12,7 @@ def load_specified_adapter(driver: Driver, adapter: str):
try:
module = importlib.import_module(adapter)
adapter = module.Adapter
- driver.register_adapter(adapter) # type:ignore
+ driver.register_adapter(adapter) # type: ignore
except ImportError:
print(f"\33[35m{adapter}不存在,请检查拼写错误或是否已安装该适配器?")
sys.exit(1)
diff --git a/muicebot/llm/embeddings/gemini.py b/muicebot/llm/embeddings/gemini.py
index 8082c0e..76dcbe1 100644
--- a/muicebot/llm/embeddings/gemini.py
+++ b/muicebot/llm/embeddings/gemini.py
@@ -19,7 +19,7 @@ async def embed(self, texts: list[str]) -> EmbeddingsBatchResult:
"""
查询文本嵌入
"""
- result = await self.client.aio.models.embed_content(model=self.model, contents=texts) # type:ignore
+ result = await self.client.aio.models.embed_content(model=self.model, contents=texts) # type: ignore
if not result.embeddings:
raise RuntimeError("Gemini 嵌入查询无返回!")
diff --git a/muicebot/llm/providers/dashscope.py b/muicebot/llm/providers/dashscope.py
index 8aaa0eb..e24d7c0 100644
--- a/muicebot/llm/providers/dashscope.py
+++ b/muicebot/llm/providers/dashscope.py
@@ -275,7 +275,7 @@ async def _tool_calls_handle_sync(
messages.append(response.output.choices[0].message)
messages.append({"role": "tool", "content": function_return, "tool_call_id": tool_call_id})
- return await self._ask(messages, tools, response_format, total_tokens) # type:ignore
+ return await self._ask(messages, tools, response_format, total_tokens) # type: ignore
async def _tool_calls_handle_stream(
self,
@@ -296,7 +296,7 @@ async def _tool_calls_handle_stream(
"""
function_args = json.loads(func_stream.function_args)
- function_return = await function_call_handler(func_stream.function_name, function_args) # type:ignore
+ function_return = await function_call_handler(func_stream.function_name, function_args) # type: ignore
messages.append(
{
@@ -317,7 +317,7 @@ async def _tool_calls_handle_stream(
)
messages.append({"role": "tool", "content": function_return, "tool_call_id": func_stream.id})
- return await self._ask(messages, tools, response_format, total_tokens) # type:ignore
+ return await self._ask(messages, tools, response_format, total_tokens) # type: ignore
async def _ask(
self,
diff --git a/muicebot/llm/providers/gemini.py b/muicebot/llm/providers/gemini.py
index 66c613e..ff07ed2 100644
--- a/muicebot/llm/providers/gemini.py
+++ b/muicebot/llm/providers/gemini.py
@@ -98,7 +98,7 @@ def _build_gemini_config(
tool["parameters"]["required"] = required_parameters
format_tools.append(tool)
- function_tools = Tool(function_declarations=format_tools) # type:ignore
+ function_tools = Tool(function_declarations=format_tools) # type: ignore
if self.enable_search:
function_tools.google_search = GoogleSearch()
@@ -123,7 +123,7 @@ def _build_user_parts(self, request: ModelRequest) -> list[Part]:
if resource.type == "image" and resource.path is not None:
user_parts.append(
Part.from_bytes(
- data=get_file_base64(resource.path), mime_type=resource.mimetype or "image/jpeg" # type:ignore
+ data=get_file_base64(resource.path), mime_type=resource.mimetype or "image/jpeg" # type: ignore
)
)
@@ -157,8 +157,8 @@ async def _ask_sync(
try:
chat = self.client.aio.chats.create(model=self.model_name, config=gemini_config, history=messages[:-1])
- message = messages[-1].parts # type:ignore
- response = await chat.send_message(message=message) # type:ignore
+ message = messages[-1].parts # type: ignore
+ response = await chat.send_message(message=message) # type: ignore
if response.usage_metadata:
total_token_count = response.usage_metadata.total_token_count
total_tokens += total_token_count if total_token_count else 0
@@ -182,10 +182,10 @@ async def _ask_sync(
function_name = function_call.name
function_args = function_call.args
- function_return = await function_call_handler(function_name, function_args) # type:ignore
+ function_return = await function_call_handler(function_name, function_args) # type: ignore
function_response_part = Part.from_function_response(
- name=function_name, # type:ignore
+ name=function_name, # type: ignore
response={"result": function_return},
)
@@ -254,10 +254,10 @@ async def _ask_stream(
function_name = function_call.name
function_args = function_call.args
- function_return = await function_call_handler(function_name, function_args) # type:ignore
+ function_return = await function_call_handler(function_name, function_args) # type: ignore
function_response_part = Part.from_function_response(
- name=function_name, # type:ignore
+ name=function_name, # type: ignore
response={"result": function_return},
)
diff --git a/muicebot/llm/providers/ollama.py b/muicebot/llm/providers/ollama.py
index 82f1015..ef415c4 100644
--- a/muicebot/llm/providers/ollama.py
+++ b/muicebot/llm/providers/ollama.py
@@ -170,13 +170,13 @@ async def _ask_stream(
if not tool_calls:
continue
- for tool in tool_calls: # type:ignore
+ for tool in tool_calls: # type: ignore
function_name = tool.function.name
function_args = tool.function.arguments
function_return = await function_call_handler(function_name, dict(function_args))
- messages.append(chunk.message) # type:ignore
+ messages.append(chunk.message) # type: ignore
messages.append({"role": "tool", "content": str(function_return), "name": tool.function.name})
async for content in self._ask_stream(messages, tools, response_format):
diff --git a/muicebot/llm/providers/openai.py b/muicebot/llm/providers/openai.py
index 31ccbe1..213c705 100644
--- a/muicebot/llm/providers/openai.py
+++ b/muicebot/llm/providers/openai.py
@@ -40,7 +40,7 @@ def __init__(self, model_config: ModelConfig) -> None:
self.max_tokens = self.config.max_tokens
self.temperature = self.config.temperature
self.stream = self.config.stream
- self.modalities = [m for m in self.config.modalities if m in {"text", "audio"}] or NOT_GIVEN # type:ignore
+ self.modalities = [m for m in self.config.modalities if m in {"text", "audio"}] or NOT_GIVEN # type: ignore
self.audio = self.config.audio if (self.modalities and self.config.audio) else NOT_GIVEN
self.extra_body = self.config.extra_body
@@ -148,20 +148,20 @@ async def _ask_sync(
logger.debug(f"OpenAI response: id={response.id}, choices={response.choices}, usage={response.usage}")
result = ""
- message = response.choices[0].message # type:ignore
+ message = response.choices[0].message # type: ignore
total_tokens += response.usage.total_tokens if response.usage else 0
if (
- hasattr(message, "reasoning_content") # type:ignore
- and message.reasoning_content # type:ignore
+ hasattr(message, "reasoning_content") # type: ignore
+ and message.reasoning_content # type: ignore
):
- result += f"{message.reasoning_content}" # type:ignore
+ result += f"{message.reasoning_content}" # type: ignore
if response.choices[0].finish_reason == "tool_calls" and self._tool_call_request_precheck(
response.choices[0].message
):
messages.append(response.choices[0].message)
- tool_call = response.choices[0].message.tool_calls[0] # type:ignore
+ tool_call = response.choices[0].message.tool_calls[0] # type: ignore
arguments = json.loads(tool_call.function.arguments.replace("'", '"'))
function_return = await function_call_handler(tool_call.function.name, arguments)
@@ -176,8 +176,8 @@ async def _ask_sync(
)
return await self._ask_sync(messages, tools, response_format, total_tokens)
- if message.content: # type:ignore
- result += message.content # type:ignore
+ if message.content: # type: ignore
+ result += message.content # type: ignore
# 多模态消息处理(目前仅支持 audio 输出)
if response.choices[0].message.audio:
@@ -259,10 +259,8 @@ async def _ask_stream(
answer_content = delta.content
# 处理思维过程 reasoning_content
- if (
- hasattr(delta, "reasoning_content") and delta.reasoning_content # type:ignore
- ):
- reasoning_content = chunk.choices[0].delta.reasoning_content # type:ignore
+ if hasattr(delta, "reasoning_content") and delta.reasoning_content: # type: ignore
+ reasoning_content = chunk.choices[0].delta.reasoning_content # type: ignore
stream_completions.chunk = (
reasoning_content if is_insert_think_label else "" + reasoning_content
)
@@ -278,7 +276,7 @@ async def _ask_stream(
# 处理多模态消息 (audio-only) (非标准方法,可能出现问题)
if hasattr(chunk.choices[0].delta, "audio"):
- audio = chunk.choices[0].delta.audio # type:ignore
+ audio = chunk.choices[0].delta.audio # type: ignore
if audio.get("data", None):
audio_string += audio.get("data")
stream_completions.chunk = audio.get("transcript", "")
@@ -366,6 +364,6 @@ async def ask(
response_format = NOT_GIVEN
if stream:
- return self._ask_stream(messages, tools, response_format) # type:ignore
+ return self._ask_stream(messages, tools, response_format) # type: ignore
- return await self._ask_sync(messages, tools, response_format) # type:ignore
+ return await self._ask_sync(messages, tools, response_format) # type: ignore
diff --git a/muicebot/onebot.py b/muicebot/onebot.py
index a830e6e..8a754c9 100644
--- a/muicebot/onebot.py
+++ b/muicebot/onebot.py
@@ -385,14 +385,12 @@ async def handle_command_profile(
@command_model.assign("help")
async def handle_model_help():
- await UniMessage(
- """Model 命令指南:
+ await UniMessage("""Model 命令指南:
- help: 显示此帮助信息
- load : 加载模型配置
- reload: 重新加载模型配置文件
- list: 列出所有可用的模型配置
- """
- ).finish()
+ """).finish()
@command_reload.handle()
@@ -484,7 +482,7 @@ async def _extract_multi_resource(
path = await download_file(resource.url, file_name=_get_media_filename(resource, type))
elif resource.origin is not None:
logger.warning("无法通过通用方式获取文件URL,回退至适配器自有方式...")
- path = await get_file_via_adapter(resource.origin, event) # type:ignore
+ path = await get_file_via_adapter(resource.origin, event) # type: ignore
else:
continue
diff --git a/muicebot/plugin/func_call/caller.py b/muicebot/plugin/func_call/caller.py
index 1a339e9..7b83550 100644
--- a/muicebot/plugin/func_call/caller.py
+++ b/muicebot/plugin/func_call/caller.py
@@ -57,7 +57,7 @@ def __call__(self, func: F) -> F:
if is_coroutine_callable(func):
self.function = func # type: ignore
else:
- self.function = async_wrap(func) # type:ignore
+ self.function = async_wrap(func) # type: ignore
self._name = func.__name__
diff --git a/muicebot/plugin/loader.py b/muicebot/plugin/loader.py
index d3a46d2..e4b0037 100644
--- a/muicebot/plugin/loader.py
+++ b/muicebot/plugin/loader.py
@@ -104,7 +104,7 @@ def _get_caller_plugin_name() -> Optional[str]:
# find plugin
frame = current_frame
- while frame := frame.f_back: # type:ignore
+ while frame := frame.f_back: # type: ignore
module_name = (module := inspect.getmodule(frame)) and module.__name__
if module_name is None: