Skip to content

Commit f663438

Browse files
fix(agentkit): OpenAISTT required fields, Deepgram keyterm, VertexAILLM URL, LLM precedence, TurnDetection language cleanup
- OpenAISTT.to_config: change default model to gpt-4o-mini-transcribe; validate that model, prompt, and language are present after applying input_audio_transcription overrides - DeepgramSTTOptions: add keyterm field emitted as params.keyterm - OpenAITTSOptions: strengthen empty check from to for base_url/model - VertexAILLM.to_config: construct correct Vertex AI endpoint URL from location/project_id/model - _resolve_llm_config: vendor-provided keys now win over agent-level convenience fields - Remove bare en from TurnDetectionLanguage and TURN_DETECTION_LANGUAGE_VALUES
1 parent fdfa4ac commit f663438

4 files changed

Lines changed: 24 additions & 12 deletions

File tree

src/agora_agent/agentkit/agent.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ class SessionOptions(typing_extensions.TypedDict, total=False):
221221
"zh-HK",
222222
"zh-TW",
223223
"nl-NL",
224-
"en",
225224
"en-IN",
226225
"en-US",
227226
"fil-PH",
@@ -258,7 +257,6 @@ class SessionOptions(typing_extensions.TypedDict, total=False):
258257
"zh-HK",
259258
"zh-TW",
260259
"nl-NL",
261-
"en",
262260
"en-IN",
263261
"en-US",
264262
"fil-PH",
@@ -944,17 +942,15 @@ def to_properties(
944942

945943
def _resolve_llm_config(self) -> typing.Dict[str, typing.Any]:
946944
llm_config = dict(self._llm or {})
947-
# Agent-level fields take priority over the vendor's defaults.
948-
# This matches the TS SDK where agent-level values override vendor config.
949-
if self._instructions is not None:
945+
if self._instructions is not None and "system_messages" not in llm_config:
950946
llm_config["system_messages"] = [{"role": "system", "content": self._instructions}]
951-
if self._greeting is not None:
947+
if self._greeting is not None and "greeting_message" not in llm_config:
952948
llm_config["greeting_message"] = self._greeting
953-
if self._greeting_configs is not None:
949+
if self._greeting_configs is not None and "greeting_configs" not in llm_config:
954950
llm_config["greeting_configs"] = _dump_optional_model(self._greeting_configs)
955-
if self._failure_message is not None:
951+
if self._failure_message is not None and "failure_message" not in llm_config:
956952
llm_config["failure_message"] = self._failure_message
957-
if self._max_history is not None:
953+
if self._max_history is not None and "max_history" not in llm_config:
958954
llm_config["max_history"] = self._max_history
959955
return llm_config
960956

src/agora_agent/agentkit/vendors/llm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,14 @@ def to_config(self) -> Dict[str, Any]:
376376
options = _dump_optional_model(self.options)
377377
options.pop("project_id", None)
378378
options.pop("location", None)
379+
if not options.get("url"):
380+
options["url"] = (
381+
f"https://{self.options.location}-aiplatform.googleapis.com/v1/projects/"
382+
f"{self.options.project_id}/locations/{self.options.location}/"
383+
f"publishers/google/models/{self.options.model}:streamGenerateContent?alt=sse"
384+
)
379385
config = Gemini(**options).to_config()
380-
params = dict(config["params"])
386+
params = dict(config.get("params") or {})
381387
params["project_id"] = self.options.project_id
382388
params["location"] = self.options.location
383389
config["params"] = params

src/agora_agent/agentkit/vendors/stt.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class DeepgramSTTOptions(BaseModel):
4444
api_key: Optional[str] = Field(default=None, description="Deepgram API key")
4545
model: Optional[str] = Field(default=None, description="Model (e.g., nova-2, enhanced, base)")
4646
language: Optional[str] = Field(default=None, description="Language code (e.g., en-US)")
47+
keyterm: Optional[str] = Field(default=None, description="Boost specialized terms and brands for Deepgram")
4748
smart_format: Optional[bool] = Field(default=None, description="Enable smart formatting")
4849
punctuation: Optional[bool] = Field(default=None, description="Enable punctuation")
4950
additional_params: Optional[Dict[str, Any]] = Field(default=None)
@@ -71,6 +72,8 @@ def to_config(self) -> Dict[str, Any]:
7172
params["smart_format"] = self.options.smart_format
7273
if self.options.punctuation is not None:
7374
params["punctuation"] = self.options.punctuation
75+
if self.options.keyterm is not None:
76+
params["keyterm"] = self.options.keyterm
7477
config: Dict[str, Any] = {
7578
"vendor": "deepgram",
7679
"params": params,
@@ -124,13 +127,20 @@ def to_config(self) -> Dict[str, Any]:
124127
params: Dict[str, Any] = dict(self.options.additional_params or {})
125128
params["api_key"] = self.options.api_key
126129

127-
transcription = {"model": "whisper-1", **(self.options.input_audio_transcription or {})}
130+
transcription: Dict[str, Any] = {"model": "gpt-4o-mini-transcribe"}
131+
transcription.update(self.options.input_audio_transcription or {})
128132
if self.options.model is not None:
129133
transcription["model"] = self.options.model
130134
if self.options.prompt is not None:
131135
transcription["prompt"] = self.options.prompt
132136
if self.options.language is not None:
133137
transcription["language"] = self.options.language
138+
if not transcription.get("model"):
139+
raise ValueError("OpenAISTT: input_audio_transcription.model is required")
140+
if not transcription.get("prompt"):
141+
raise ValueError("OpenAISTT: input_audio_transcription.prompt is required")
142+
if not transcription.get("language"):
143+
raise ValueError("OpenAISTT: input_audio_transcription.language is required")
134144
params["input_audio_transcription"] = transcription
135145

136146
config: Dict[str, Any] = {

src/agora_agent/agentkit/vendors/tts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _validate_byok_params(self) -> "OpenAITTSOptions":
114114
("model", self.model),
115115
("base_url", self.base_url),
116116
)
117-
if value is None
117+
if not value
118118
]
119119
if missing:
120120
raise ValueError(f"OpenAITTS requires {', '.join(missing)} when api_key is set")

0 commit comments

Comments
 (0)