Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add text streaming support #24

Merged
merged 7 commits into from
May 18, 2023

Conversation

valdemardi
Copy link
Contributor

This change allows you to stream text from the API to the console word-by-word similar to what the official WebUI does.

@efJerryYang
Copy link
Owner

Thank you for your contributions!

I've often considered this feature, but haven't had the free time recently for implementing it. Your efforts have made it a reality. 👍

@efJerryYang
Copy link
Owner

I will merge it after reviewing your commits later.

@efJerryYang
Copy link
Owner

I add a vertical_overflow="visible" option for the streaming method Live so that it will automatically scroll the terminal if the maximum height is reached when streaming.

However, there is still a tiny problem if I fixed it in this way - the earlier message history on the terminal would be awful with too many duplicated lines. A simple solution to this could be typing !show command to redisplay the current conversation, but I think it might be better if this can be performed automatically after each time of the streaming (I guess). Would you like to add this feature to this thread if you have time @vahlgren ?

Anyway, I will merge this PR tomorrow morning regardless of my updated request as the earlier feature you added was truly useful enough and you can revert my commit if you think the fix here is not appropriate (maybe you once tried this method but discarded it finally). You can drop my commits and force-push to update the remote.

Again, thanks for your contributions!

@valdemardi
Copy link
Contributor Author

I add a vertical_overflow="visible" option for the streaming method Live so that it will automatically scroll the terminal if the maximum height is reached when streaming.

Nice, I think that is better than just displaying three the dots when the vertical space runs out, even with the messed up scroll history.

However, there is still a tiny problem if I fixed it in this way - the earlier message history on the terminal would be awful with too many duplicated lines. A simple solution to this could be typing !show command to redisplay the current conversation, but I think it might be better if this can be performed automatically after each time of the streaming (I guess). Would you like to add this feature to this thread if you have time @vahlgren ?

I could not immediately figure out a good way to make this work nicely. One option would have been using Live(screen=True) while the text is being streamed, and when complete, the alternative screen would disappear with all intermediate content, making it possible to do a clean print of the whole message leaving the scroll back history nice and clean. Sadly this did not seem to work well in practice because the Live view in screen=True mode is stuck following the top of the screen only.

I'll create another pull request later if I manage to figure out how to deal with this.

Again, thanks for your contributions!

Thank you for the cli app! I like it a lot more than using the WebUI 😄

@efJerryYang efJerryYang force-pushed the add-streaming-support branch from 91b9a7b to 0554922 Compare May 18, 2023 04:58
@efJerryYang efJerryYang merged commit 2c66170 into efJerryYang:main May 18, 2023
@efJerryYang
Copy link
Owner

I fixed it by adding a show_history() in the main loop function, and the issue was resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants