1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::;
use AgentEvent;
use mpsc;
/// Send a single message and wait for the complete text response.
///
/// This is the simplest way to use the library — an agent is created,
/// started, the message is sent, and the agent is stopped automatically.
///
/// # Example
/// ```rust,no_run
/// use agent_diva_nano::{chat, NanoConfig};
///
/// # async fn example() -> Result<(), agent_diva_nano::NanoError> {
/// let config = NanoConfig {
/// model: "deepseek-chat".to_string(),
/// api_key: std::env::var("API_KEY").unwrap(),
/// ..Default::default()
/// };
/// let response = chat("Explain Rust ownership", &config).await?;
/// println!("{}", response);
/// # Ok(())
/// # }
/// ```
pub async
/// Send a single message and receive a stream of [`AgentEvent`]s.
///
/// The returned channel yields events such as `AssistantDelta`,
/// `ToolCallStarted`, `ToolCallFinished`, and finally `FinalResponse`.
///
/// # Example
/// ```rust,no_run
/// use agent_diva_nano::{chat_stream, NanoConfig};
///
/// # async fn example() -> Result<(), agent_diva_nano::NanoError> {
/// let config = NanoConfig {
/// model: "deepseek-chat".to_string(),
/// api_key: std::env::var("API_KEY").unwrap(),
/// ..Default::default()
/// };
/// let mut rx = chat_stream("Explain Rust ownership", &config).await?;
/// while let Some(event) = rx.recv().await {
/// println!("{:?}", event);
/// }
/// # Ok(())
/// # }
/// ```
pub async