[router] move tokenizer, reasoning, tool initialization to server (#9996)
This commit is contained in:
@@ -13,12 +13,15 @@ use std::sync::{Arc, Mutex, OnceLock};
|
||||
|
||||
/// Helper function to create AppContext for tests
|
||||
pub fn create_test_context(config: RouterConfig) -> Arc<AppContext> {
|
||||
Arc::new(AppContext::new(
|
||||
config.clone(),
|
||||
reqwest::Client::new(),
|
||||
config.max_concurrent_requests,
|
||||
config.rate_limit_tokens_per_second,
|
||||
))
|
||||
Arc::new(
|
||||
AppContext::new(
|
||||
config.clone(),
|
||||
reqwest::Client::new(),
|
||||
config.max_concurrent_requests,
|
||||
config.rate_limit_tokens_per_second,
|
||||
)
|
||||
.expect("Failed to create AppContext in test"),
|
||||
)
|
||||
}
|
||||
|
||||
// Tokenizer download configuration
|
||||
|
||||
@@ -15,12 +15,15 @@ pub fn create_test_app(
|
||||
router_config: &RouterConfig,
|
||||
) -> Router {
|
||||
// Create AppContext
|
||||
let app_context = Arc::new(AppContext::new(
|
||||
router_config.clone(),
|
||||
client,
|
||||
router_config.max_concurrent_requests,
|
||||
router_config.rate_limit_tokens_per_second,
|
||||
));
|
||||
let app_context = Arc::new(
|
||||
AppContext::new(
|
||||
router_config.clone(),
|
||||
client,
|
||||
router_config.max_concurrent_requests,
|
||||
router_config.rate_limit_tokens_per_second,
|
||||
)
|
||||
.expect("Failed to create AppContext in test"),
|
||||
);
|
||||
|
||||
// Create AppState with the test router and context
|
||||
let app_state = Arc::new(AppState {
|
||||
|
||||
@@ -195,7 +195,8 @@ mod test_pd_routing {
|
||||
|
||||
// Router creation will fail due to health checks, but config should be valid
|
||||
let app_context =
|
||||
sglang_router_rs::server::AppContext::new(config, reqwest::Client::new(), 64, None);
|
||||
sglang_router_rs::server::AppContext::new(config, reqwest::Client::new(), 64, None)
|
||||
.expect("Failed to create AppContext");
|
||||
let app_context = std::sync::Arc::new(app_context);
|
||||
let result = RouterFactory::create_router(&app_context).await;
|
||||
assert!(result.is_err());
|
||||
|
||||
Reference in New Issue
Block a user