Skip to content

Commit fa61404

Browse files
committed
feat: update default ASR vendor selection based on client area; enhance documentation and tests
1 parent 4f83e51 commit fa61404

8 files changed

Lines changed: 41 additions & 4 deletions

File tree

docs/concepts/agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ agent = Agent(client=client).with_llm(
4646
| `rtc` | `RtcConfig` | No | RTC media encryption |
4747
| `filler_words` | `FillerWordsConfig` | No | Filler words while waiting for LLM |
4848

49-
When `client` is provided, `Agent(client=...)` returns `CNAgent` for `Area.CN` and `GlobalAgent` for global areas.
49+
When `client` is provided, `Agent(client=...)` returns `CNAgent` for `Area.CN` and `GlobalAgent` for global areas. If `with_stt()` is omitted, the bound client also determines the default ASR vendor: `Fengming` for `Area.CN`, otherwise `Ares`.
5050

5151
## Builder Methods
5252

docs/concepts/vendors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ tts = ElevenLabsTTS(
103103

104104
Used with `agent.with_stt()`.
105105

106-
Use `turn_detection.language` for Agora interaction language; it defaults to `en-US`. STT vendor `language` options are serialized under `asr.params` using each provider's own format. Ares does not take a provider language option; AgentKit uses `turn_detection.language` for REST `asr.language`.
106+
Use `turn_detection.language` for Agora interaction language; it defaults to `en-US`. STT vendor `language` options are serialized under `asr.params` using each provider's own format. If `with_stt()` is omitted, AgentKit defaults to `AresSTT` for global clients and `FengmingSTT` for `Area.CN` clients. Ares does not take a provider language option; AgentKit uses `turn_detection.language` for REST `asr.language`.
107107

108108
| Class | Provider | Required Parameters |
109109
|---|---|---|

docs/guides/regional-routing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ client = Agora(
3636
## Recommended vendors by area
3737

3838
Bind `client` into `Agent(client=client, ...)` and construct vendors directly with SDK classes. The bound client selects `CNAgent` or `GlobalAgent` for IDE hints based on `area`, but does not restrict which vendor classes you can configure.
39+
If you omit `with_stt()`, AgentKit uses `FengmingSTT` by default for `Area.CN` clients and `AresSTT` for global clients.
3940

4041
| Client area | STT classes | LLM classes | TTS classes | Avatar classes |
4142
|---|---|---|---|---|
@@ -125,6 +126,7 @@ agent = Agent(client=client, turn_detection={"language": "zh-CN"})
125126
```
126127

127128
`Agent(client=...)` returns `CNAgent` for `Area.CN` and `GlobalAgent` for global areas. A bound `client` is required. The SDK does not reject mismatched vendor classes at build time or session start.
129+
The same bound client also controls the default ASR vendor when `with_stt()` is omitted.
128130

129131
## How the domain pool works
130132

docs/reference/agent.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description: Full API reference for the Python Agent builder class.
99
**Import:** `from agora_agent import Agent, CNAgent, GlobalAgent`
1010

1111
Bind the client on every `Agent` builder via `Agent(client=client, ...)`, then pass vendor classes directly. The bound client sets the API routing region and provides area-specific IDE hints via `CNAgent` / `GlobalAgent`:
12+
it also selects the default ASR vendor when `with_stt()` is omitted (`Fengming` for `Area.CN`, otherwise `Ares`).
1213

1314
> **`client` is required.** `create_session()` and `create_async_session()` raise `ValueError` if no client was bound on the agent.
1415

docs/reference/vendors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ The SDK also includes named helpers for the remaining Agora-supported LLM provid
412412

413413
## STT Vendors
414414

415-
Use `turn_detection.language` for Agora interaction language; it defaults to `en-US`. Provider-specific language values remain under `asr.params` and may use a different format. AgentKit populates REST `asr.language` from `turn_detection.language`.
415+
Use `turn_detection.language` for Agora interaction language; it defaults to `en-US`. Provider-specific language values remain under `asr.params` and may use a different format. If `with_stt()` is omitted, AgentKit defaults to `AresSTT` for global clients and `FengmingSTT` for `Area.CN` clients. AgentKit populates REST `asr.language` from `turn_detection.language`.
416416

417417
### `SpeechmaticsSTT`
418418

src/agora_agent/agentkit/agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,8 @@ def _resolve_llm_config(self) -> typing.Dict[str, typing.Any]:
10781078
def _resolve_asr_config(self, turn_detection_config: TurnDetectionInput) -> typing.Dict[str, typing.Any]:
10791079
asr_config = dict(self._stt or {})
10801080
if not asr_config:
1081-
asr_config["vendor"] = "ares"
1081+
area_scope = getattr(self._client, "area_scope", None)
1082+
asr_config["vendor"] = "fengming" if area_scope == "cn" else "ares"
10821083
asr_config["language"] = self._field_value(turn_detection_config, "language")
10831084
return asr_config
10841085

tests/custom/test_regional_vendors.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ def test_agent_constructor_auto_selects_area_aware_subclass() -> None:
6666
assert global_agent.__class__.__name__ == "GlobalAgent"
6767

6868

69+
def test_default_asr_vendor_is_area_aware_when_with_stt_is_omitted() -> None:
70+
cn_properties = Agent(client=_client(Area.CN)).to_properties(
71+
channel="room",
72+
agent_uid="1",
73+
remote_uids=["100"],
74+
token="rtc-token",
75+
)
76+
global_properties = Agent(client=_client(Area.US)).to_properties(
77+
channel="room",
78+
agent_uid="1",
79+
remote_uids=["100"],
80+
token="rtc-token",
81+
)
82+
83+
assert cn_properties.asr is not None
84+
assert cn_properties.asr.vendor == "fengming"
85+
assert global_properties.asr is not None
86+
assert global_properties.asr.vendor == "ares"
87+
88+
6989
def test_cn_client_allows_global_only_vendor() -> None:
7090
client = _client(Area.CN)
7191
agent = Agent(client=client).with_stt(

tests/custom/test_stt_language.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from agora_agent import (
44
Agent,
5+
Area,
56
AmazonSTT,
67
AssemblyAISTT,
78
DeepgramSTT,
@@ -85,6 +86,18 @@ def test_default_turn_detection_language_is_sent_without_stt() -> None:
8586
assert props["turn_detection"] == {"language": "en-US"}
8687

8788

89+
def test_default_stt_vendor_depends_on_client_area_when_stt_is_omitted() -> None:
90+
global_props = properties(base_agent())
91+
cn_props = properties(
92+
Agent(test_client(area=Area.CN))
93+
.with_llm(OpenAI(api_key="llm-key", model="gpt-4o-mini", base_url="https://api.openai.com/v1/chat/completions"))
94+
.with_tts(ElevenLabsTTS(key="tts-key", voice_id="voice", model_id="eleven_flash_v2_5", base_url="wss://api.elevenlabs.io/v1"))
95+
)
96+
97+
assert global_props["asr"] == {"vendor": "ares", "language": "en-US"}
98+
assert cn_props["asr"] == {"vendor": "fengming", "language": "en-US"}
99+
100+
88101
def test_stt_vendor_params_match_documented_shapes() -> None:
89102
deepgram_managed = DeepgramSTT(model="nova-3", language="en-US").to_config()
90103
assert "language" not in deepgram_managed

0 commit comments

Comments
 (0)