Skip to content

Commit a9a1d36

Browse files
committed
fix : Support streaming to pipe. #43
1 parent a2ea3eb commit a9a1d36

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/pytgpt/console.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,13 +1071,18 @@ def for_non_stream():
10711071
busy_bar.start_spinning()
10721072
generated_response = generate_response()
10731073

1074-
if normal_stdout:
1075-
# Resolves : https://github.com/Simatwa/python-tgpt/issues/42
1074+
if normal_stdout or not self.prettify and not self.disable_stream:
1075+
# Resolves : https://github.com/Simatwa/python-tgpt/issues/42 & 43
10761076
cached_response: str = ""
1077+
if not normal_stdout:
1078+
busy_bar.stop_spinning()
10771079
for response in generated_response:
1080+
offset = len(cached_response)
1081+
print(response[offset:], end="")
10781082
cached_response = response
1079-
pass
1080-
print(cached_response)
1083+
if not normal_stdout:
1084+
# Interactive prompt
1085+
print("")
10811086
return
10821087

10831088
if self.quiet:

0 commit comments

Comments
 (0)