|
53 | 53 | (deftest normalize-messages-test |
54 | 54 | (testing "With tool_call history - assistant text and tool calls are merged" |
55 | 55 | (is (match? |
56 | | - [{:role "user" :content [{:type "text" :text "List the files"}]} |
| 56 | + [{:role "user" :content "List the files"} |
57 | 57 | {:role "assistant" |
58 | | - :content [{:type "text" :text "I'll list the files for you"}] |
| 58 | + :content "I'll list the files for you" |
59 | 59 | :tool_calls [{:id "call-1" |
60 | 60 | :type "function" |
61 | 61 | :function {:name "eca__list_files" |
62 | 62 | :arguments "{}"}}]} |
63 | 63 | {:role "tool" |
64 | 64 | :tool_call_id "call-1" |
65 | 65 | :content "file1.txt\nfile2.txt\n"} |
66 | | - {:role "assistant" :content [{:type "text" :text "I found 2 files"}]}] |
| 66 | + {:role "assistant" :content "I found 2 files"}] |
67 | 67 | (#'llm-providers.openai-chat/normalize-messages |
68 | 68 | [{:role "user" :content "List the files"} |
69 | 69 | {:role "assistant" :content "I'll list the files for you"} |
|
81 | 81 |
|
82 | 82 | (testing "Reason messages without reasoning-content use think tags, merged with following assistant" |
83 | 83 | (is (match? |
84 | | - [{:role "user" :content [{:type "text" :text "Hello"}]} |
85 | | - {:role "assistant" :content [{:type "text" :text "<think>Thinking...</think>"} |
86 | | - {:type "text" :text "Hi"}]}] |
| 84 | + [{:role "user" :content "Hello"} |
| 85 | + {:role "assistant" :content "<think>Thinking...</think>\nHi"}] |
87 | 86 | (#'llm-providers.openai-chat/normalize-messages |
88 | 87 | [{:role "user" :content "Hello"} |
89 | 88 | {:role "reason" :content {:text "Thinking..."}} |
|
93 | 92 | thinking-end-tag))))) |
94 | 93 |
|
95 | 94 | (deftest extract-content-test |
96 | | - (testing "String input" |
97 | | - (is (= [{:type "text" :text "Hello world"}] |
| 95 | + (testing "String input - returns string for text-only content" |
| 96 | + (is (= "Hello world" |
98 | 97 | (#'llm-providers.openai-chat/extract-content " Hello world " true)))) |
99 | 98 |
|
100 | 99 | (testing "Sequential messages with actual format" |
|
161 | 160 | thinking-end-tag)))) |
162 | 161 |
|
163 | 162 | (testing "Reason messages - use reasoning_content if :delta-reasoning?, otherwise tags" |
164 | | - ;; Without :delta-reasoning?, uses think tags |
| 163 | + ;; Without :delta-reasoning?, uses think tags (string, not array - for Gemini compatibility) |
165 | 164 | (is (match? |
166 | 165 | {:role "assistant" |
167 | | - :content [{:type "text" :text "<think>Reasoning...</think>"}]} |
| 166 | + :content "<think>Reasoning...</think>"} |
168 | 167 | (#'llm-providers.openai-chat/transform-message |
169 | 168 | {:role "reason" |
170 | 169 | :content {:text "Reasoning..."}} |
|
372 | 371 | ;; After normalization, all tool_calls should be merged into one assistant message |
373 | 372 | ;; followed by all tool outputs, then the final assistant message |
374 | 373 | (is (match? |
375 | | - [{:role "user" :content [{:type "text" :text "Read two files"}]} |
| 374 | + [{:role "user" :content "Read two files"} |
376 | 375 | {:role "assistant" |
377 | 376 | :tool_calls [{:id "call-1" :function {:name "eca__read_file"}} |
378 | 377 | {:id "call-2" :function {:name "eca__read_file"}}]} |
379 | 378 | {:role "tool" :tool_call_id "call-1" :content "content1\n"} |
380 | 379 | {:role "tool" :tool_call_id "call-2" :content "content2\n"} |
381 | | - {:role "assistant" :content [{:type "text" :text "I read both files"}]}] |
| 380 | + {:role "assistant" :content "I read both files"}] |
382 | 381 | normalized) |
383 | 382 | "Tool calls must be grouped together before their outputs"))) |
384 | 383 |
|
|
421 | 420 | [{:role "user"} |
422 | 421 | {:role "assistant" :tool_calls [{:id "call-1"}]} |
423 | 422 | {:role "tool" :tool_call_id "call-1"} |
424 | | - {:role "assistant" :content [{:type "text" :text "First response"}]} |
| 423 | + {:role "assistant" :content "First response"} |
425 | 424 | {:role "user"} |
426 | 425 | {:role "assistant" :tool_calls [{:id "call-2"}]} |
427 | 426 | {:role "tool" :tool_call_id "call-2"} |
428 | | - {:role "assistant" :content [{:type "text" :text "Second response"}]}] |
| 427 | + {:role "assistant" :content "Second response"}] |
429 | 428 | normalized))))) |
430 | 429 |
|
431 | 430 | (deftest gemini-thought-signature-test |
|
527 | 526 | {:role "assistant" |
528 | 527 | :tool_calls [{:id "call-2" :function {:name "tool2"}}]} |
529 | 528 | {:role "tool" :tool_call_id "call-2" :content "r2\n"} |
530 | | - {:role "assistant" :content [{:type "text" :text "Done"}]}] |
| 529 | + {:role "assistant" :content "Done"}] |
531 | 530 | normalized))))) |
532 | 531 |
|
533 | 532 | (deftest tool-call-order-by-index-test |
|
768 | 767 | (is (= "think more" (:reason-text result))) |
769 | 768 | (is (some? (:reasoning-content result)) "reasoning-content should be present in non-streaming result") |
770 | 769 | (is (match? |
771 | | - [{:role "user" :content [{:type "text" :text "Q"}]} |
| 770 | + [{:role "user" :content "Q"} |
772 | 771 | {:role "assistant" |
773 | 772 | :reasoning_content "think more"}] |
774 | 773 | normalized))))) |
0 commit comments