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
//! Streaming events -- what a streaming Text request yields incrementally,
//! instead of making you wait for the entire reply. See
//! [`PendingTextRequest::stream`](crate::text::PendingTextRequest::stream).
use ;
use crateTextResponse;
use crate;
/// One event in a streamed reply.
///
/// A single [`stream`](crate::text::PendingTextRequest::stream) call produces a
/// sequence shaped like: one [`StreamStart`](StreamEvent::StreamStart), then any
/// number of [`TextDelta`](StreamEvent::TextDelta) /
/// [`ToolCallDelta`](StreamEvent::ToolCallDelta) events as the model's reply
/// arrives, a [`ToolCall`](StreamEvent::ToolCall) once each tool call has fully
/// arrived, a [`StepFinish`](StreamEvent::StepFinish) once that round trip is
/// done -- and then, if the model asked to call a tool, a
/// [`ToolResult`](StreamEvent::ToolResult) for each one that ran, followed by
/// another `StreamStart` for the next round trip. The whole sequence ends with
/// exactly one [`StreamEnd`](StreamEvent::StreamEnd).
///
/// Errors are reported through the `Result` the stream itself yields (`Result
/// <StreamEvent, Error>`), not as a variant of this enum -- so you only need to
/// check one place for something having gone wrong.