pub async fn query_stream_with_timeout(
prompt: &str,
timeout_secs: f64,
) -> Result<impl Stream<Item = String>>Expand description
Stream responses from iFlow with custom timeout
Sends a query to iFlow and returns a stream of response chunks. This is useful for real-time output as the response is generated.
§Arguments
prompt- The query prompt to send to iFlowtimeout_secs- Timeout in seconds
§Returns
Ok(impl Stream<Item = String>)containing the response streamErr(IFlowError)if there was an error
§Example
use iflow_cli_sdk_rust::query_stream_with_timeout;
use futures::stream::StreamExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut stream = query_stream_with_timeout("Tell me a story", 120.0).await?;
while let Some(chunk) = stream.next().await {
print!("{}", chunk);
// Flush stdout for real-time output
use std::io::{self, Write};
io::stdout().flush()?;
}
Ok(())
}