Unverified Commit af4ab656 authored by Chang Su's avatar Chang Su Committed by GitHub
Browse files

[router][tool call] Improve normal content extraction and error handling (non-stream) (#11050)

parent 11965b0d
...@@ -118,8 +118,12 @@ async fn test_json_extraction_without_wrapper_tokens() { ...@@ -118,8 +118,12 @@ async fn test_json_extraction_without_wrapper_tokens() {
And here is some text after. And here is some text after.
"#; "#;
let (_normal_text, tools) = parser.parse_complete(input).await.unwrap(); let (normal_text, tools) = parser.parse_complete(input).await.unwrap();
assert_eq!(tools.len(), 1); assert_eq!(tools.len(), 1);
assert_eq!(
normal_text,
"\n Here is some text before the JSON.\n \n And here is some text after.\n "
);
assert_eq!(tools[0].function.name, "search"); assert_eq!(tools[0].function.name, "search");
} }
...@@ -143,8 +147,9 @@ async fn test_json_with_multiline_wrapper_content() { ...@@ -143,8 +147,9 @@ async fn test_json_with_multiline_wrapper_content() {
``` ```
Done!"#; Done!"#;
let (_normal_text, tools) = parser.parse_complete(input).await.unwrap(); let (normal_text, tools) = parser.parse_complete(input).await.unwrap();
assert_eq!(tools.len(), 1); assert_eq!(tools.len(), 1);
assert_eq!(normal_text, "");
assert_eq!(tools[0].function.name, "format_code"); assert_eq!(tools[0].function.name, "format_code");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment