MCPcopy Create free account
hub / github.com/NVIDIA/NeMo-Relay / register_llm_stream_execution_intercept

Method register_llm_stream_execution_intercept

crates/python/src/py_plugin.rs:528–560  ·  view source on GitHub ↗
(
        &self,
        name: &str,
        priority: i32,
        callback: Py<PyAny>,
    )

Source from the content-addressed store, hash-verified

526
527 #[pyo3(signature = (name: "str", priority: "int", callback: "object") -> "None", text_signature = "(name: str, priority: int, callback: object) -> None")]
528 fn register_llm_stream_execution_intercept(
529 &self,
530 name: &str,
531 priority: i32,
532 callback: Py<PyAny>,
533 ) -> PyResult<()> {
534 let qualified_name = self.qualify_name(name);
535 register_llm_stream_execution_intercept(
536 &qualified_name,
537 priority,
538 wrap_py_llm_stream_exec_intercept_fn(callback),
539 )
540 .map_err(to_py_err)?;
541
542 let name_owned = qualified_name;
543 let mut guard = self.registrations.lock().map_err(|e| {
544 pyo3::exceptions::PyRuntimeError::new_err(format!("plugin context lock poisoned: {e}"))
545 })?;
546 guard.push(PluginRegistration::new(
547 "plugin",
548 name_owned.clone(),
549 Box::new(move || {
550 deregister_llm_stream_execution_intercept(&name_owned)
551 .map(|_| ())
552 .map_err(|e| {
553 PluginError::RegistrationFailed(format!(
554 "llm stream execution intercept deregistration failed: {e}"
555 ))
556 })
557 }),
558 ));
559 Ok(())
560 }
561
562 #[pyo3(signature = (
563 name: "str",