[model-gateway] Dynamically Populate Tool Call Parser Choices (#14807)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use pyo3::prelude::*;
|
||||
use sgl_model_gateway::*;
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::collections::HashMap;
|
||||
|
||||
// Define the enums with PyO3 bindings
|
||||
@@ -730,6 +731,18 @@ fn get_verbose_version_string() -> String {
|
||||
version::get_verbose_version_string()
|
||||
}
|
||||
|
||||
/// Get the list of available tool call parsers from the Rust factory.
|
||||
#[pyfunction]
|
||||
fn get_available_tool_call_parsers() -> Vec<String> {
|
||||
static PARSERS: OnceCell<Vec<String>> = OnceCell::new();
|
||||
PARSERS
|
||||
.get_or_init(|| {
|
||||
let factory = tool_parser::ParserFactory::new();
|
||||
factory.list_parsers()
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
|
||||
#[pymodule]
|
||||
fn sglang_router_rs(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||
m.add_class::<PolicyType>()?;
|
||||
@@ -740,5 +753,6 @@ fn sglang_router_rs(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||
m.add_class::<Router>()?;
|
||||
m.add_function(wrap_pyfunction!(get_version_string, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(get_verbose_version_string, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(get_available_tool_call_parsers, m)?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user