feat(asr): add model vendor metadata across providers - #2265
Conversation
Review:
|
6b95a9a to
d625d6f
Compare
|
Review: feat(asr): add model vendor metadata across providers Consistent, well-scoped change: five providers gain a model key in vendor_metadata(), each with a paired test and a patch version bump in both manifest.json and pyproject.toml. The 1. Google and Sarvam read params, but the model lives on a top-level field Both extensions load config and then immediately flatten params onto the model: self.config = GoogleASRConfig.model_validate_json(config_json)
self.config.update(self.config.params) # copies params["model"] -> self.config.modelGoogleASRConfig.model defaults to "long" and SarvamASRConfig.model to "saarika:v2.5", and both are what the request path actually uses:
The new vendor_metadata() reads Reading the resolved field is both simpler and accurate: def vendor_metadata(self) -> dict[str, Any]:
if self.config is None:
return {}
return {"model": self.config.model} if self.config.model else {}This mirrors tencent_asr_python, which reads self.request_params.engine_model_type, the resolved value, not the raw params dict. Worth adding a test that calls 2. Aliyun: params is never populated, and the config class is malformed vendor_metadata() reads
So this returns {} in every real configuration, and would report a model that has no effect on the request even if someone set one. The new test passes only because it injects params.model by hand. Consider dropping the Aliyun override, or, if the goal is a uniform telemetry shape, wiring params["model"] into the actual start_connection() call first so the reported value is real. Separately, and pre-existing but directly adjacent: AliyunASRConfig is declared as both @DataClass and BaseModel, with 3. OpenAI: model_dump() on every call is avoidable, and couples to the encryption serializer transcription = self.config.params.model_dump().get("input_audio_transcription", {})Params is a Pydantic model with
Direct attribute access avoids both: transcription = getattr(self.config.params, "input_audio_transcription", None) or {}
model = transcription.get("model") if isinstance(transcription, dict) else Noneinput_audio_transcription arrives from property.json as a plain dict (see openai_asr_client/client.py:356, which passes a dict literal), so the isinstance check already present is the right instinct: keep it. 4. ByteDance: reads raw params["request"], bypassing the default The extension uses The sibling fields in the same dict already use accessors (get_api_url(), get_app_key(), and so on). Following that pattern keeps the reported value equal to the sent value: try:
request = self.config.get_request_config()
except ValueError:
request = {}
fields = {..., "model": request.get("model_name")}The try matters: get_request_config() raises ValueError when params.request is absent, and vendor_metadata() is called from error paths where raising would mask the original error. Also note config.py:162 mutates 5. Test collection is worth verifying locally The five test_vendor_metadata.py files use relative imports (
Both are environment questions I could not verify here. A local tests/bin/start run per extension would confirm all ten new tests are collected and green. Minor
Security No new secret exposure. Each override returns only a model name, and the truthiness filter keeps empty values out. The OpenAI model_dump() point above is the only place worth tightening, and it is about avoiding unnecessary handling of api_key rather than an actual leak. Summary The pattern and structure are right. The core issue is that four of the five implementations read the raw params dict while the request path reads a resolved value, either a default or a flattened field, so metadata can disagree with what was actually sent, and for Aliyun it likely reports nothing in any real config. Reading the same value the client sends fixes all four and simplifies the code. The tests pass because they construct config in a way that skips the resolution step, so they would not catch this today. |
Expose configured model names for Aliyun, ByteDance, Google, OpenAI, and Sarvam ASR extensions, with tests and patch version bumps.
d625d6f to
5ef5608
Compare
Expose configured model names for Aliyun, ByteDance, Google, OpenAI, and Sarvam ASR extensions, with tests and patch version bumps.