|
27 | 27 | validate_avatar_config, |
28 | 28 | validate_tts_sample_rate, |
29 | 29 | ) |
30 | | -from .presets import resolve_session_presets |
| 30 | +from .presets import ( |
| 31 | + get_preset_category, |
| 32 | + infer_asr_preset, |
| 33 | + infer_llm_preset, |
| 34 | + infer_tts_preset, |
| 35 | + normalize_preset_input, |
| 36 | + resolve_session_presets, |
| 37 | +) |
31 | 38 | from .token import generate_convo_ai_token, _parse_numeric_uid |
32 | 39 |
|
33 | 40 |
|
@@ -294,15 +301,17 @@ def _is_mllm_mode(self) -> bool: |
294 | 301 | def _build_start_properties( |
295 | 302 | self, |
296 | 303 | token_opts: typing.Dict[str, typing.Any], |
297 | | - skip_vendor_validation: bool, |
| 304 | + skip_vendor_validation_categories: typing.AbstractSet[str], |
| 305 | + allow_missing_vendor_categories: typing.AbstractSet[str], |
298 | 306 | ) -> typing.Dict[str, typing.Any]: |
299 | 307 | base_properties = self._agent.to_properties( |
300 | 308 | channel=self._channel, |
301 | 309 | agent_uid=self._agent_uid, |
302 | 310 | remote_uids=self._remote_uids, |
303 | 311 | idle_timeout=self._idle_timeout, |
304 | 312 | enable_string_uid=self._enable_string_uid, |
305 | | - skip_vendor_validation=skip_vendor_validation, |
| 313 | + skip_vendor_validation_categories=skip_vendor_validation_categories, |
| 314 | + allow_missing_vendor_categories=allow_missing_vendor_categories, |
306 | 315 | **token_opts, |
307 | 316 | ) |
308 | 317 | properties = self._dump_model(base_properties) |
@@ -340,6 +349,29 @@ def _build_start_properties( |
340 | 349 |
|
341 | 350 | return properties |
342 | 351 |
|
| 352 | + def _vendor_validation_categories( |
| 353 | + self, |
| 354 | + pipeline_id: typing.Optional[str], |
| 355 | + ) -> typing.Tuple[typing.Set[str], typing.Set[str]]: |
| 356 | + skip_categories: typing.Set[str] = set() |
| 357 | + allow_missing_categories: typing.Set[str] = {"asr", "llm", "tts"} if pipeline_id else set() |
| 358 | + |
| 359 | + preset = normalize_preset_input(self._preset) |
| 360 | + if preset: |
| 361 | + for item in preset.split(","): |
| 362 | + category = get_preset_category(item) |
| 363 | + if category is not None: |
| 364 | + skip_categories.add(category) |
| 365 | + allow_missing_categories.add(category) |
| 366 | + |
| 367 | + if infer_asr_preset(self._agent.stt): |
| 368 | + skip_categories.add("asr") |
| 369 | + if infer_llm_preset(self._agent.llm): |
| 370 | + skip_categories.add("llm") |
| 371 | + if infer_tts_preset(self._agent.tts): |
| 372 | + skip_categories.add("tts") |
| 373 | + return skip_categories, allow_missing_categories |
| 374 | + |
343 | 375 | @staticmethod |
344 | 376 | def _page_value(pagination: typing.Any, field: str) -> typing.Any: |
345 | 377 | if pagination is None: |
@@ -460,7 +492,12 @@ def start(self) -> str: |
460 | 492 | "expires_in": self._expires_in, |
461 | 493 | } |
462 | 494 |
|
463 | | - properties = self._build_start_properties(token_opts, skip_vendor_validation=bool(self._preset or pipeline_id)) |
| 495 | + skip_categories, allow_missing_categories = self._vendor_validation_categories(pipeline_id) |
| 496 | + properties = self._build_start_properties( |
| 497 | + token_opts, |
| 498 | + skip_vendor_validation_categories=skip_categories, |
| 499 | + allow_missing_vendor_categories=allow_missing_categories, |
| 500 | + ) |
464 | 501 | resolved_preset, resolved_properties = resolve_session_presets( |
465 | 502 | self._preset, |
466 | 503 | properties, |
@@ -782,7 +819,12 @@ async def start(self) -> str: |
782 | 819 | "expires_in": self._expires_in, |
783 | 820 | } |
784 | 821 |
|
785 | | - properties = self._build_start_properties(token_opts, skip_vendor_validation=bool(self._preset or pipeline_id)) |
| 822 | + skip_categories, allow_missing_categories = self._vendor_validation_categories(pipeline_id) |
| 823 | + properties = self._build_start_properties( |
| 824 | + token_opts, |
| 825 | + skip_vendor_validation_categories=skip_categories, |
| 826 | + allow_missing_vendor_categories=allow_missing_categories, |
| 827 | + ) |
786 | 828 | resolved_preset, resolved_properties = resolve_session_presets( |
787 | 829 | self._preset, |
788 | 830 | properties, |
|
0 commit comments