"examples/vscode:/vscode.git/clone" did not exist on "f4e208105b3db99e4f79be60fde2b925b8f2b71c"
Unverified Commit 427ca9ab authored by Yan Ru Pei's avatar Yan Ru Pei Committed by GitHub
Browse files

chore: no need for explicit Python::with_gil (#4075)


Signed-off-by: default avatarPeaBrane <yanrpei@gmail.com>
parent 17af7a0f
...@@ -1115,8 +1115,6 @@ impl KvPushRouter { ...@@ -1115,8 +1115,6 @@ impl KvPushRouter {
extra_args: Option<PyObject>, extra_args: Option<PyObject>,
) -> PyResult<Bound<'p, PyAny>> { ) -> PyResult<Bound<'p, PyAny>> {
// Depythonize the options with defaults // Depythonize the options with defaults
let (stop_conditions, sampling_options, output_options, router_config_override, extra_args) =
Python::with_gil(|py| {
let stop_conditions: StopConditions = if let Some(obj) = stop_conditions { let stop_conditions: StopConditions = if let Some(obj) = stop_conditions {
depythonize(obj.bind(py)).map_err(to_pyerr)? depythonize(obj.bind(py)).map_err(to_pyerr)?
} else { } else {
...@@ -1148,15 +1146,6 @@ impl KvPushRouter { ...@@ -1148,15 +1146,6 @@ impl KvPushRouter {
None None
}; };
Ok::<_, PyErr>((
stop_conditions,
sampling_options,
output_options,
router_config_override,
extra_args,
))
})?;
// Build the PreprocessedRequest // Build the PreprocessedRequest
let mut request_builder = let mut request_builder =
llm_rs::protocols::common::preprocessor::PreprocessedRequest::builder(); llm_rs::protocols::common::preprocessor::PreprocessedRequest::builder();
...@@ -1188,7 +1177,7 @@ impl KvPushRouter { ...@@ -1188,7 +1177,7 @@ impl KvPushRouter {
) -> PyResult<Bound<'p, PyAny>> { ) -> PyResult<Bound<'p, PyAny>> {
// Depythonize the request directly into PreprocessedRequest // Depythonize the request directly into PreprocessedRequest
let request: llm_rs::protocols::common::preprocessor::PreprocessedRequest = let request: llm_rs::protocols::common::preprocessor::PreprocessedRequest =
Python::with_gil(|py| depythonize(request.bind(py)).map_err(to_pyerr))?; depythonize(request.bind(py)).map_err(to_pyerr)?;
// Use the helper method to process the request // Use the helper method to process the request
Self::process_request_to_stream(py, self.inner.clone(), request) Self::process_request_to_stream(py, self.inner.clone(), request)
...@@ -1203,11 +1192,9 @@ impl KvPushRouter { ...@@ -1203,11 +1192,9 @@ impl KvPushRouter {
request_id: Option<String>, request_id: Option<String>,
) -> PyResult<Bound<'p, PyAny>> { ) -> PyResult<Bound<'p, PyAny>> {
let router_config_override = if let Some(obj) = router_config_override { let router_config_override = if let Some(obj) = router_config_override {
Python::with_gil(|py| {
let override_config: llm_rs::kv_router::RouterConfigOverride = let override_config: llm_rs::kv_router::RouterConfigOverride =
depythonize(obj.bind(py)).map_err(to_pyerr)?; depythonize(obj.bind(py)).map_err(to_pyerr)?;
Ok::<_, PyErr>(Some(override_config)) Some(override_config)
})?
} else { } else {
None None
}; };
...@@ -1250,11 +1237,9 @@ impl KvPushRouter { ...@@ -1250,11 +1237,9 @@ impl KvPushRouter {
)?; )?;
let router_config_override = if let Some(obj) = router_config_override { let router_config_override = if let Some(obj) = router_config_override {
Python::with_gil(|py| {
let override_config: llm_rs::kv_router::RouterConfigOverride = let override_config: llm_rs::kv_router::RouterConfigOverride =
depythonize(obj.bind(py)).map_err(to_pyerr)?; depythonize(obj.bind(py)).map_err(to_pyerr)?;
Ok::<_, PyErr>(Some(override_config)) Some(override_config)
})?
} else { } else {
None None
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment