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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
//! The provider-author toolkit: the steps every adapter shares around
//! encoding a request and decoding a response.
//!
//! Applications do not need this module. It is for code that implements
//! [`ChatProvider`](crate::ChatProvider),
//! [`EmbeddingProvider`](crate::EmbeddingProvider) or
//! [`DecisionProvider`](crate::DecisionProvider) against a wire API: a
//! provider crate, or an application's own adapter for an in-house
//! gateway. The [provider authors' guide] walks through it.
//!
//! - [`chat`]: [`prepare`](chat::prepare) and
//! [`prepare_dry_run`](chat::prepare_dry_run), which check a request and
//! carry its warnings through encoding to the response
//! ([`Prepared`](chat::Prepared)), so the same encoding serves the call
//! and its dry run (validation); [`preflight`](chat::preflight), the
//! capability check `prepare` runs before encoding (ADR 0003);
//! [`WireSupport`](chat::WireSupport) and
//! [`Prepared::degrade_to`](chat::Prepared::degrade_to), which refuse or
//! drop what a wire format cannot carry; [`retain_turns`](chat::retain_turns),
//! the pass over the encoded turns; [`start_first`](chat::start_first),
//! the rule for the events a stream yields before its `ResponseStart`;
//! [`MISSING_FINISH_REASON`](chat::MISSING_FINISH_REASON); and
//! [`ToolCallIdFormat`](chat::ToolCallIdFormat), which maps the tool call
//! ids of a history from another provider to ones the wire accepts.
//! - [`embedding`] and [`decision`]: the same `prepare` step for the other
//! operations, and [`check_response`](embedding::check_response) for
//! embedding vectors.
//! - [`schema`]: the JSON Schema passes adapters compose into a provider's
//! dialect, and the strict-schema policy.
//! - [`Degradations`]: the warnings and refusals a request collects while
//! it is encoded.
//!
//! Stream decoders also use [`MetadataBuilder`](crate::chat::stream::MetadataBuilder)
//! and [`StreamCollector`](crate::chat::stream::StreamCollector) from
//! [`chat::stream`](crate::chat::stream), which applications use too.
//!
pub use crateDegradations;
/// The namespaces some state came from, for a warning or error message:
/// `` `openai`, `gemini` ``, or "an unknown origin" when there are none.
///
/// Adapters name the origin of the replayed state they drop
/// ([`Degradations::dropped_replay_state`]) with it, so every adapter
/// words it the same way.
///
/// ```
/// use allama::adapter::describe_origins;
///
/// assert_eq!(describe_origins(&["openai", "gemini"]), "`openai`, `gemini`");
/// // One optional origin, such as `OtherContent::origin`:
/// let origin: Option<&str> = None;
/// assert_eq!(describe_origins(origin.as_slice()), "an unknown origin");
/// ```