Commit 681ff50
committed
Fix(stream): Correct newline handling in streaming functions
Refactored `ollama_generate_stream` to use a more robust method for
handling streaming responses, similar to `ollama_chat_stream`.
This change fixes a bug where newlines were not being handled correctly
in the streaming output. The new implementation uses `jq -r` to extract
and unescape the response content, and `printf '%s'` to print the raw
string without interpreting escape sequences. This ensures that newlines
and other special characters in the model's response are rendered
correctly.
The `ollama_chat_stream` function was also reviewed and found to be
already using the correct approach.1 parent a1cb014 commit 681ff50
1 file changed
+17
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
756 | 756 | | |
757 | 757 | | |
758 | 758 | | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
793 | 764 | | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
798 | 771 | | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
805 | 778 | | |
806 | 779 | | |
807 | 780 | | |
| |||
0 commit comments