Skip to content

Commit 003660c

Browse files
committed
fix(regional_agent): narrow return type only, not vendor params
Narrowing the param types statically enforced the very vendor/area compatibility PR #37 says it does NOT enforce (and which tests exercise cross-region). Keep the -> CNAgent/-> GlobalAgent return narrowing for fluent chaining; accept the base vendor types. Valid override, no type: ignore.
1 parent 07e810a commit 003660c

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

src/agora_agent/agentkit/regional_agent.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,31 +108,31 @@
108108

109109

110110
class CNAgent(Agent):
111-
def with_stt(self, vendor: CNSTT) -> "CNAgent":
112-
return typing.cast("CNAgent", super().with_stt(typing.cast(BaseSTT, vendor)))
111+
def with_stt(self, vendor: BaseSTT) -> "CNAgent":
112+
return typing.cast("CNAgent", super().with_stt(vendor))
113113

114-
def with_llm(self, vendor: CNLLM) -> "CNAgent":
115-
return typing.cast("CNAgent", super().with_llm(typing.cast(BaseLLM, vendor)))
114+
def with_llm(self, vendor: BaseLLM) -> "CNAgent":
115+
return typing.cast("CNAgent", super().with_llm(vendor))
116116

117-
def with_tts(self, vendor: CNTTS) -> "CNAgent":
118-
return typing.cast("CNAgent", super().with_tts(typing.cast(BaseTTS, vendor)))
117+
def with_tts(self, vendor: BaseTTS) -> "CNAgent":
118+
return typing.cast("CNAgent", super().with_tts(vendor))
119119

120-
def with_avatar(self, vendor: CNAvatar) -> "CNAgent":
121-
return typing.cast("CNAgent", super().with_avatar(typing.cast(BaseAvatar, vendor)))
120+
def with_avatar(self, vendor: BaseAvatar) -> "CNAgent":
121+
return typing.cast("CNAgent", super().with_avatar(vendor))
122122

123123

124124
class GlobalAgent(Agent):
125-
def with_stt(self, vendor: GlobalSTT) -> "GlobalAgent":
126-
return typing.cast("GlobalAgent", super().with_stt(typing.cast(BaseSTT, vendor)))
125+
def with_stt(self, vendor: BaseSTT) -> "GlobalAgent":
126+
return typing.cast("GlobalAgent", super().with_stt(vendor))
127127

128-
def with_llm(self, vendor: GlobalLLM) -> "GlobalAgent":
129-
return typing.cast("GlobalAgent", super().with_llm(typing.cast(BaseLLM, vendor)))
128+
def with_llm(self, vendor: BaseLLM) -> "GlobalAgent":
129+
return typing.cast("GlobalAgent", super().with_llm(vendor))
130130

131-
def with_tts(self, vendor: GlobalTTS) -> "GlobalAgent":
132-
return typing.cast("GlobalAgent", super().with_tts(typing.cast(BaseTTS, vendor)))
131+
def with_tts(self, vendor: BaseTTS) -> "GlobalAgent":
132+
return typing.cast("GlobalAgent", super().with_tts(vendor))
133133

134-
def with_avatar(self, vendor: GlobalAvatar) -> "GlobalAgent":
135-
return typing.cast("GlobalAgent", super().with_avatar(typing.cast(BaseAvatar, vendor)))
134+
def with_avatar(self, vendor: BaseAvatar) -> "GlobalAgent":
135+
return typing.cast("GlobalAgent", super().with_avatar(vendor))
136136

137137

138138
RegionalAgent = typing.Union[CNAgent, GlobalAgent]

0 commit comments

Comments
 (0)