File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -237,4 +237,32 @@ mod tests {
237
237
let result = client. chat ( input) . await ;
238
238
assert ! ( result. is_err( ) ) ;
239
239
}
240
+
241
+ #[ test]
242
+ fn test_usage_struct ( ) {
243
+ let usage = Usage {
244
+ prompt_tokens : 10 ,
245
+ completion_tokens : 20 ,
246
+ total_tokens : 30 ,
247
+ } ;
248
+
249
+ assert_eq ! ( usage. prompt_tokens, 10 ) ;
250
+ assert_eq ! ( usage. completion_tokens, 20 ) ;
251
+ assert_eq ! ( usage. total_tokens, 30 ) ;
252
+ }
253
+
254
+ #[ test]
255
+ fn test_choice_struct ( ) {
256
+ let choice = Choice {
257
+ message : Message {
258
+ role : Role :: Assistant ,
259
+ content : "Sample response" . to_string ( ) ,
260
+ } ,
261
+ finish_reason : "stop" . to_string ( ) ,
262
+ } ;
263
+
264
+ assert_eq ! ( choice. message. role, Role :: Assistant ) ;
265
+ assert_eq ! ( choice. message. content, "Sample response" ) ;
266
+ assert_eq ! ( choice. finish_reason, "stop" ) ;
267
+ }
240
268
}
Original file line number Diff line number Diff line change @@ -149,4 +149,29 @@ mod tests {
149
149
let deserialized_model: Model = serde_json:: from_str ( model_json) . unwrap ( ) ;
150
150
assert_eq ! ( deserialized_model, Model :: Gpt_4 ) ;
151
151
}
152
+
153
+ #[ test]
154
+ fn test_logit_bias_struct ( ) {
155
+ let mut biases = HashMap :: new ( ) ;
156
+ biases. insert ( 42 , 2.5 ) ;
157
+ biases. insert ( 123 , -1.3 ) ;
158
+
159
+ let logit_bias = LogitBias { biases } ;
160
+
161
+ assert_eq ! (
162
+ logit_bias. biases. get( & 42 ) ,
163
+ Some ( & 2.5 ) ,
164
+ "Bias for token 42 should be 2.5"
165
+ ) ;
166
+ assert_eq ! (
167
+ logit_bias. biases. get( & 123 ) ,
168
+ Some ( & -1.3 ) ,
169
+ "Bias for token 123 should be -1.3"
170
+ ) ;
171
+ assert_eq ! (
172
+ logit_bias. biases. get( & 999 ) ,
173
+ None ,
174
+ "Bias for token 999 should not be set"
175
+ ) ;
176
+ }
152
177
}
You can’t perform that action at this time.
0 commit comments