Skip to main content

query_stream

Function query_stream 

Source
pub async fn query_stream(
    prompt: &str,
    options: Option<LlmOptions>,
) -> Result<impl Stream<Item = Result<String>>>
Expand description

Send a prompt and get a stream of text chunks.

Each item is an incremental text delta (not cumulative). Useful for real-time display of streaming responses.

ยงExample

use futures::StreamExt;

let mut stream = cc_sdk::llm::query_stream("Write a poem", None).await?;
while let Some(chunk) = stream.next().await {
    print!("{}", chunk?);
}