Skip to content

Commit b1cb211

Browse files
juntaoclaude
andcommitted
Restore realtime router with #[allow(deprecated)]
Keep the /v1/realtime endpoint functional while suppressing deprecation warnings with targeted #[allow(deprecated)] attributes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7162ce4 commit b1cb211

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

src/main.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use axum::{
77
use clap::Parser;
88
use config::Config;
99

10+
#[allow(deprecated)]
11+
use crate::{config::ASRConfig, services::realtime_ws::StableRealtimeConfig};
1012

1113
pub mod ai;
1214
pub mod config;
@@ -54,14 +56,25 @@ async fn routes(
5456
});
5557

5658
let mut tool_set = ai::openai::tool::ToolSet::default();
59+
#[allow(deprecated)]
60+
let mut real_config: Option<StableRealtimeConfig> = None;
5761

5862
// todo: support other configs
63+
#[allow(deprecated)]
5964
match &config.config {
6065
config::AIConfig::Stable {
6166
llm: config::LLMConfig::OpenAIChat(chat_llm),
62-
tts: _,
63-
asr: _,
67+
tts,
68+
asr,
6469
} => {
70+
if let ASRConfig::Whisper(asr) = asr {
71+
real_config = Some(StableRealtimeConfig {
72+
llm: chat_llm.clone(),
73+
tts: tts.clone(),
74+
asr: asr.clone(),
75+
});
76+
}
77+
6578
for server in &chat_llm.mcp_server {
6679
match server.type_ {
6780
config::MCPType::SSE => {
@@ -163,6 +176,17 @@ async fn routes(
163176
)))
164177
.layer(axum::Extension(record_config.clone()));
165178

179+
#[allow(deprecated)]
180+
if let Some(real_config) = real_config {
181+
log::info!(
182+
"Adding realtime WebSocket handler with config: {:?}",
183+
real_config
184+
);
185+
router = router
186+
.route("/v1/realtime", any(services::realtime_ws::ws_handler))
187+
.layer(axum::Extension(Arc::new(real_config)));
188+
}
189+
166190
router.route(
167191
"/version",
168192
get(|| async {

0 commit comments

Comments
 (0)