Skip to content

fix(mimo): 修复voice design模型请求中包含无效voice参数的问题#8326

Open
NayukiChiba wants to merge 2 commits into
AstrBotDevs:masterfrom
NayukiChiba:fix/8283-mimo-voicedesign
Open

fix(mimo): 修复voice design模型请求中包含无效voice参数的问题#8326
NayukiChiba wants to merge 2 commits into
AstrBotDevs:masterfrom
NayukiChiba:fix/8283-mimo-voicedesign

Conversation

@NayukiChiba
Copy link
Copy Markdown
Contributor

@NayukiChiba NayukiChiba commented May 25, 2026

mimo-v2.5-tts-voicedesign模型不支持audio.voice参数,之前统一添加导致请求可能出错

Modifications / 改动点

  • 在构建请求payload时根据模型名称动态决定是否包含voice字段
  • 增加单元测试覆盖voicedesign模型和普通模型的参数构建逻辑

close #8283

asttbot/core/provider/sources/mimo_tts_api_source.py中,如果模型名字中没有voicedesign就使用voice,有的话就不用

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

test session starts
platform win32 -- Python 3.12.12, pytest-9.0.2, pluggy-1.6.0
rootdir: D:\Nayey\Code\NayukiChiba\AstrBot
configfile: pyproject.toml
plugins: anyio-4.12.1, asyncio-1.3.0, cov-7.0.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 12 items                                                                                     

tests\test_mimo_api_sources.py ............                                                      [100%]
 12 passed in 1.31s

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Conditionally omit unsupported audio.voice parameter for mimo TTS voice design models to prevent invalid requests.

Bug Fixes:

  • Avoid sending audio.voice in requests for mimo-v2.5-tts-voicedesign models, which do not support this parameter.

Tests:

  • Add unit tests verifying that voice design models omit audio.voice while regular mimo TTS models include it in the request payload.

- voice design模型不支持audio.voice参数,之前统一添加导致请求可能出错
- 在构建请求payload时根据模型名称动态决定是否包含voice字段
- 增加单元测试覆盖voicedesign模型和普通模型的参数构建逻辑

close AstrBotDevs#8283
@auto-assign auto-assign Bot requested review from Fridemn and LIghtJUNction May 25, 2026 11:29
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. labels May 25, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In _build_payload, rename audioParams to audio_params to keep variable naming consistent with Python’s snake_case convention used elsewhere in the file.
  • The check if "voicedesign" not in self.model_name relies on a substring; consider tightening this to a more explicit condition (e.g., endswith("-voicedesign") or a dedicated helper) to avoid accidental matches if future model names contain voicedesign in other contexts.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `_build_payload`, rename `audioParams` to `audio_params` to keep variable naming consistent with Python’s snake_case convention used elsewhere in the file.
- The check `if "voicedesign" not in self.model_name` relies on a substring; consider tightening this to a more explicit condition (e.g., `endswith("-voicedesign")` or a dedicated helper) to avoid accidental matches if future model names contain `voicedesign` in other contexts.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Mimo TTS API source to conditionally exclude the voice parameter from the payload when using 'voicedesign' models, supported by new unit tests. The review feedback recommends renaming the audioParams variable to audio_params to comply with PEP 8 standards and using case-insensitive matching for the model name to enhance robustness.

Comment on lines +91 to +99
audioParams = {"format": self.audio_format}
# voice design 模型不支持 audio.voice 参数
if "voicedesign" not in self.model_name:
audioParams["voice"] = self.voice

return {
"model": self.model_name,
"messages": messages,
"audio": {
"format": self.audio_format,
"voice": self.voice,
},
"audio": audioParams,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

这里有三个改进建议:

  1. 变量名 audioParams 使用了小驼峰命名法,建议改为蛇形命名法 audio_params 以符合 PEP 8 规范并与上下文保持一致。
  2. 建议在检查模型名称时使用 self.model_name.lower(),以确保匹配逻辑对大小写不敏感,提高代码的健壮性。
  3. 根据项目规范,新增的功能逻辑(如 TTS 适配)应当包含相应的单元测试以确保稳定性。
Suggested change
audioParams = {"format": self.audio_format}
# voice design 模型不支持 audio.voice 参数
if "voicedesign" not in self.model_name:
audioParams["voice"] = self.voice
return {
"model": self.model_name,
"messages": messages,
"audio": {
"format": self.audio_format,
"voice": self.voice,
},
"audio": audioParams,
audio_params = {"format": self.audio_format}
# voice design 模型不支持 audio.voice 参数
if "voicedesign" not in self.model_name.lower():
audio_params["voice"] = self.voice
return {
"model": self.model_name,
"messages": messages,
"audio": audio_params,
References
  1. PEP 8: 变量名应使用小写字母,单词之间用下划线分隔,以提高可读性。 (link)
  2. New functionality, such as handling attachments, should be accompanied by corresponding unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[文本转语音TTS不支持mimo-v2.5-tts-voicedesign]

1 participant