MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / warmup

Method warmup

python/src/llm/client.rs:764–795  ·  view source on GitHub ↗

Warmup the client with a test request

(&self, py: Python<'a>)

Source from the content-addressed store, hash-verified

762
763 /// Warmup the client with a test request
764 fn warmup<'a>(&self, py: Python<'a>) -> PyResult<Bound<'a, PyAny>> {
765 let warmed_up = Arc::clone(&self.warmed_up);
766 let provider = Arc::clone(&self.provider);
767 let debug = self.config.debug; // Capture debug flag before async move
768
769 pyo3_async_runtimes::tokio::future_into_py(py, async move {
770 warmed_up
771 .get_or_init(|| async {
772 if debug {
773 info!("Warming up LLM client...");
774 }
775 let test_request = LlmRequest::new("Hello".to_string());
776 let guard = provider.read().await;
777
778 if let Err(e) = guard.complete(test_request).await {
779 if debug {
780 warn!(
781 "Warmup request failed (this is expected for some providers): {}",
782 e
783 );
784 }
785 }
786
787 if debug {
788 info!("LLM client warmup completed");
789 }
790 })
791 .await;
792
793 Ok("Client warmed up successfully".to_string())
794 })
795 }
796
797 /// Reset client statistics
798 fn reset_stats(&self) -> PyResult<()> {

Calls 2

to_stringMethod · 0.80
completeMethod · 0.45