From a9a1d36e6c4b45eda3ae925a589b22ce3ec2aca6 Mon Sep 17 00:00:00 2001 From: smartwa Date: Mon, 15 Apr 2024 12:32:10 +0300 Subject: [PATCH] fix : Support streaming to pipe. #43 --- src/pytgpt/console.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pytgpt/console.py b/src/pytgpt/console.py index 479da0b..13a269c 100644 --- a/src/pytgpt/console.py +++ b/src/pytgpt/console.py @@ -1071,13 +1071,18 @@ def for_non_stream(): busy_bar.start_spinning() generated_response = generate_response() - if normal_stdout: - # Resolves : https://github.com/Simatwa/python-tgpt/issues/42 + if normal_stdout or not self.prettify and not self.disable_stream: + # Resolves : https://github.com/Simatwa/python-tgpt/issues/42 & 43 cached_response: str = "" + if not normal_stdout: + busy_bar.stop_spinning() for response in generated_response: + offset = len(cached_response) + print(response[offset:], end="") cached_response = response - pass - print(cached_response) + if not normal_stdout: + # Interactive prompt + print("") return if self.quiet: