fix(mimo): 修复voice design模型请求中包含无效voice参数的问题#8326
Open
NayukiChiba wants to merge 2 commits into
Open
Conversation
- voice design模型不支持audio.voice参数,之前统一添加导致请求可能出错 - 在构建请求payload时根据模型名称动态决定是否包含voice字段 - 增加单元测试覆盖voicedesign模型和普通模型的参数构建逻辑 close AstrBotDevs#8283
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
_build_payload, renameaudioParamstoaudio_paramsto keep variable naming consistent with Python’s snake_case convention used elsewhere in the file. - The check
if "voicedesign" not in self.model_namerelies 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 containvoicedesignin 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
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, |
Contributor
There was a problem hiding this comment.
这里有三个改进建议:
- 变量名
audioParams使用了小驼峰命名法,建议改为蛇形命名法audio_params以符合 PEP 8 规范并与上下文保持一致。 - 建议在检查模型名称时使用
self.model_name.lower(),以确保匹配逻辑对大小写不敏感,提高代码的健壮性。 - 根据项目规范,新增的功能逻辑(如 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
- PEP 8: 变量名应使用小写字母,单词之间用下划线分隔,以提高可读性。 (link)
- New functionality, such as handling attachments, should be accompanied by corresponding unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mimo-v2.5-tts-voicedesign模型不支持audio.voice参数,之前统一添加导致请求可能出错Modifications / 改动点
close #8283
在
asttbot/core/provider/sources/mimo_tts_api_source.py中,如果模型名字中没有voicedesign就使用voice,有的话就不用Screenshots or Test Results / 运行截图或测试结果
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.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.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:
Tests: