feat: add MiniMax STT API provider - #10144
murphys7017 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="astrbot/core/provider/sources/minimax_stt_api_source.py" line_range="61-62" />
<code_context>
+ temp_dir = Path(get_astrbot_temp_path())
+ temp_dir.mkdir(parents=True, exist_ok=True)
+ source_path = temp_dir / f"minimax_stt_{uuid.uuid4().hex[:8]}{suffix}"
+ await download_file(audio_source, str(source_path))
+ cleanup_paths.append(source_path)
+
+ if not source_path.exists():
</code_context>
<issue_to_address>
**issue (bug_risk):** If `download_file` creates a partial destination and then raises, the downloaded path is not added to `cleanup_paths` because it is appended only after the await completes, so the partial temporary file is leaked.
**Triggers:** When a remote audio download fails after writing any bytes.
**Suggested fix:** Add the destination path to `cleanup_paths` before awaiting `download_file`, or delete the destination in the download exception path.
```suggestion
cleanup_paths.append(source_path)
await download_file(audio_source, str(source_path))
```
</issue_to_address>
### Comment 2
<location path="astrbot/core/provider/sources/minimax_stt_api_source.py" line_range="106-108" />
<code_context>
+
+ async def get_text(self, audio_url: str) -> str:
+ audio_path, cleanup_paths = await self._prepare_audio_file(audio_url)
+ headers = {"Authorization": f"Bearer {self.chosen_api_key}"}
+ if self.language:
+ headers["language"] = self.language
+
+ try:
+ content_type = (
</code_context>
<issue_to_address>
**issue:** Configured provider `custom_headers` are never merged into the request headers, so custom authentication, routing, or gateway headers configured through the standard provider mechanism are silently omitted from every MiniMax STT request.
**Triggers:** When a MiniMax provider configuration contains `custom_headers`.
**Suggested fix:** Merge `self.request_headers` into the request headers while allowing the required Authorization and language headers to take precedence.
```suggestion
headers = {
**self.request_headers,
"Authorization": f"Bearer {self.chosen_api_key}",
}
if self.language:
headers["language"] = self.language
```
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and if the provider is wrong, enabled users may send audio to an unintended or malfunctioning MiniMax endpoint, and those external uploads cannot be retracted, though the impact is limited to opted-in transcription requests and reverting stops future calls. Transcriptions are not persisted by this change, so normal implementation defects can be repaired without data migration or recovery work.
Blocking findings: astrbot/core/provider/sources/minimax_stt_api_source.py:62, astrbot/core/provider/sources/minimax_stt_api_source.py:108
|
Addressed the Sourcery findings: partial remote downloads are now registered for cleanup before download starts, and standard custom headers are merged while the configured Authorization and language headers retain precedence. Added regression coverage; focused suite now passes 7 tests. |
Summary
Validation
uff format --check astrbot/core/provider/sources/minimax_stt_api_source.py tests/test_minimax_stt_api_source.py
uff check astrbot/core/provider/sources/minimax_stt_api_source.py tests/test_minimax_stt_api_source.py
No live MiniMax API request was made because no API key is included.
Summary by Sourcery
Add MiniMax speech-to-text support with configurable language hints and robust audio preparation.
New Features:
Enhancements:
Documentation:
Tests: