Skip to content

Commit

Permalink
fix : Support streaming to pipe. #43
Browse files Browse the repository at this point in the history
  • Loading branch information
Simatwa committed Apr 15, 2024
1 parent a2ea3eb commit a9a1d36
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pytgpt/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a9a1d36

Please sign in to comment.