Comments (36)
Example code: #5 (comment)
from chatgpt.
Opened #23
from chatgpt.
Happy to help, whether that means picking up where you left off or figuring it out from scratch...
A pull request would be much appreciated.
Perhaps there could be another parameter to get_chat_response to specify the return type: text or stream, with text as default
from chatgpt.
Ok, I'll try to take a look tomorrow. LMK if you find anything out about how it's done in the browser: I haven't done any research yet.
from chatgpt.
I implemented streaming response, but I don't know how to output it on the console.
from chatgpt.
I implemented streaming response, but I don't know how to output it on the console.
I solved the problem, but the method was ugly.
from chatgpt.
@A-kirami I have written a rough implementation of text streaming. Can you check if it works as intended (It works for me but need verification)
get_chat_response(prompt, output="stream")
should yield
each message.
if __name__ == "__main__":
with open("config.json", "r") as f:
config = json.load(f)
chatbot = Chatbot(config)
if 'session_token' in config:
chatbot.refresh_session()
while True:
prompt = input("You: ")
for message in chatbot.get_chat_response(prompt, output="stream"):
print(message)
This should print out the message as it streams. I'm not sure how to deal with the console so that it is overwritten as more data comes in.
from chatgpt.
@A-kirami I have written a rough implementation of text streaming. Can you check if it works as intended (It works for me but need verification)
get_chat_response(prompt, output="stream")
shouldyield
each message.if __name__ == "__main__": with open("config.json", "r") as f: config = json.load(f) chatbot = Chatbot(config) if 'session_token' in config: chatbot.refresh_session() while True: prompt = input("You: ") for message in chatbot.get_chat_response(prompt, output="stream"): print(message)This should print out the message as it streams. I'm not sure how to deal with the console so that it is overwritten as more data comes in.
It works normally. If you need to print it on the console, you can refer to the implementation here.
https://github.com/A-kirami/ChatGPT/blob/main/src/revChatGPT/__main__.py#L69-L81
from chatgpt.
Like this:
from chatgpt.
I am terrible at this. It keeps erasing the lines in my implementation
from chatgpt.
I'll copy your code over and modify it
from chatgpt.
This doesn't work in all terminals:
Detected that the lines of output has been exceeded the height of terminal windows, which caused the former output remained and keep adding new lines.
检测到输出过程中, 输出行数曾大于命令行窗口行数, 这会导致输出清除不完整, 而使输出不停增长。请注意控制输出行数
from chatgpt.
sys.stdout.write("\033[F\033[K")
This doesn't work properly in all terminals either for some reason. My hair is falling off lol
from chatgpt.
The error seems to be that this deletes the number of lines it is aware of but in some terminals, line count is counted differently
from chatgpt.
The approach I was attempting (but haven't perfected yet) is to only write a line once it is has completely loaded, rather than deleting lines after they're written. Would that work here?
from chatgpt.
That is what I'm attempting to do. I write the whole message and then when a new one comes in, I try to delete the previous message. It's not clearing the right number of lines though.
from chatgpt.
I'm suggesting you not try to delete the previous message (as I did with the please wait prompt), but rather keep track of how many lines you've written, and only write each new line.
from chatgpt.
keep track of how many lines you've written
Tried that. An issue with this is that some environments treat lines differently. For example, my current omz shell treats each new line in the terminal as a new line (which changes depending on window size). However, Python can only see \n as new line
from chatgpt.
I tried counting the characters and saving them, then deleting that number of characters when a new message comes in. However, \b isn't supported in some terminals either.
from chatgpt.
Not even ChatGPT knows the solution to this...
from chatgpt.
I think streaming is more suited for GUI applications. Terminals don't like overwrites
from chatgpt.
Do you have a pointer to a commit that has streaming working but doesn't have the terminal stuff solved yet? I can restart my efforts from there.
from chatgpt.
Streaming working on latest commit
from chatgpt.
Of main or async-dev?
from chatgpt.
main
from chatgpt.
On that commit I'm getting
File "/Users/sleibrand/src/ChatGPT/src/revChatGPT/__main__.py", line 70, in <module>
print("Chatbot:", response['message'])
TypeError: 'generator' object is not subscriptable
from chatgpt.
It returns a string. I didn't update the docs yet. You need to call with output="stream"
from chatgpt.
I've been running it with python3 -m revChatGPT
- is there another command-line you've been using?
from chatgpt.
I've been running it with
python3 -m revChatGPT
- is there another command-line you've been using?
It can only be implemented custom right now.
from chatgpt.
https://github.com/acheong08/ChatGPT/compare/main...scottleibrand:ChatGPT:async?expand=1
~/src/ChatGPT $ python3 -m revChatGPT
ChatGPT - A command-line interface to OpenAI's ChatGPT (https://chat.openai.com/chat)
Repo: github.com/acheong08/ChatGPT
Type '!help' to show commands
Press enter twice to submit your question.
You: test
...
I'm sorry, but I'm not sure what you're looking for. Could you please provide
more information or context? I'm a large language model trained by OpenAI, and
I'm here to help with any questions you may have.
You:
Cleaning up, then will PR.
from chatgpt.
Chatbot:
Something went wrong!
name 'formatted_parts' is not defined
from chatgpt.
I ought to have some better way to detect auth errors
from chatgpt.
Yeah, that has tripped me up a few times too. Can we store more persistent credentials to allow it to log in again?
from chatgpt.
The thing with the next auth tokens is that it needs to be refreshed every hour via !refresh. It stays valid that way. However, if you don't refresh it, it expires.
from chatgpt.
I haven't figured out their hashing system on the login page. It hashes the password client side
from chatgpt.
I'll open an issue for this
from chatgpt.
Related Issues (20)
- The Functions HOT 1
- [Feature Request]: Additions to Awesome ChatGPT HOT 1
- [Bug]: ValueError: PUID is required HOT 1
- [Bug]: Error querying GPT 4 HOT 7
- [Bug]: access_denied: Your version of the ChatGPT app is out of date. Please update to the newest build of the app. HOT 12
- [Bug]: Field missing. Details: {'conversation_id': 'abf665f2-3c8f-4725-8263-5893bb5847ff', 'message_id': 'b8fe1067-2610-4bea-b33b-93b099b3803b', 'is_completion': False, 'moderation_response': {'flagged': False, 'blocked': False, 'moderation_id': 'modr-7eEtljxtdnGEn9sCjBEKoPBeuGh7M'}} HOT 13
- ValueError: Field missing. Details: {'conversation_id': '289a9ec4-cf13-45f5-bc3f-f96046e487c7', 'message_id': 'a5be1cb9-610f-4c53-a019-73abfd2b68ab', 'is_completion': False, 'moderation_response': {'flagged': False, 'blocked': False, 'moderation_id': 'modr-7eJ0uKhi6TSRvHoiBzCxVBTu7GA2v'}} HOT 4
- [Bug]: 应该是chat.openai新更新的json返回的格式,导致了现在只有message_id,没message这个字段了 HOT 3
- [Bug]: Support for 32bit and Arm processors
- Email/Password storing the Access token HOT 3
- [Bug]: Exception(resp_json.get("error", "Unknown error")) Exception: unable to log requests HOT 2
- [Bug]: https://bypass.churchless.tech/conversation HOT 1
- I registered on https://nat.dev verified by email however I am not getting verification code on mobile and that bug is not letting me login[Bug]:
- It asks to manually input captcha HOT 8
- [Feature Request]: personal advice HOT 2
- A timeout occurred Error code 524
- [Bug]:
- revChatGPT.typings.Error: OpenAI: {"error":"Post \"https://tcr9i.chat.openai.com/fc/gt2/public_key/35536E1E-65B4-4D96-9D97-6ADB7EFF8147\": http2: server sent GOAWAY and closed the connection; LastStreamID=1, ErrCode=ENHANCE_YOUR_CALM, debug=\"\""} (code: 500) HOT 1
- [Bug]: Please check that the input is correct, or you can resolve this issue by filing an issue HOT 2
- [Bug]: access token is expired in a minute! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatgpt.