diff options
Diffstat (limited to 'tests/mock.rs')
| -rw-r--r-- | tests/mock.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/mock.rs b/tests/mock.rs index 9b9a56d..7e076e3 100644 --- a/tests/mock.rs +++ b/tests/mock.rs | |||
| @@ -442,3 +442,28 @@ fn a_final_frame_without_a_newline_is_not_lost() { | |||
| 442 | .expect("a trailing frame without a newline should still count"); | 442 | .expect("a trailing frame without a newline should still count"); |
| 443 | assert_eq!(outcome.content, "last"); | 443 | assert_eq!(outcome.content, "last"); |
| 444 | } | 444 | } |
| 445 | |||
| 446 | #[test] | ||
| 447 | fn an_empty_placeholder_tool_call_is_dropped() { | ||
| 448 | const SSE: &str = concat!( | ||
| 449 | "HTTP/1.1 200 OK\r\n", | ||
| 450 | "Content-Type: text/event-stream\r\n", | ||
| 451 | "Connection: close\r\n", | ||
| 452 | "\r\n", | ||
| 453 | "data: {\"choices\":[{\"delta\":{\"tool_calls\":[{\"index\":0,\"id\":\"call_1\",\"function\":{\"name\":\"read\",\"arguments\":\"{\\\"path\\\":\\\"a\\\"}\"}},{\"index\":1}]},\"finish_reason\":\"tool_calls\"}]}\n\n", | ||
| 454 | "data: [DONE]\n\n", | ||
| 455 | ); | ||
| 456 | let (base, _rx) = serve_once(SSE); | ||
| 457 | let mut sink = Collector::default(); | ||
| 458 | let outcome = provider::chat( | ||
| 459 | &config(base), | ||
| 460 | &[json!({ "role": "user", "content": "hi" })], | ||
| 461 | &[], | ||
| 462 | &AtomicBool::new(false), | ||
| 463 | &mut sink, | ||
| 464 | ) | ||
| 465 | .expect("chat should succeed"); | ||
| 466 | |||
| 467 | assert_eq!(outcome.tool_calls.len(), 1, "{:?}", outcome.tool_calls); | ||
| 468 | assert_eq!(outcome.tool_calls[0].name, "read"); | ||
| 469 | } | ||
