kardolus / chatgpt-cli

ChatGPT CLI is an advanced command-line interface for ChatGPT models via OpenAI and Azure, offering streaming, query mode, and history tracking for seamless, context-aware conversations. Ideal for both users and developers, it provides advanced configuration and easy setup options to ensure a tailored conversational experience with the GPT model.
MIT License
424 stars 28 forks source link

Start a new conversation #4

Closed andreaganduglia closed 1 year ago

andreaganduglia commented 1 year ago

Could be useful exclude history from context and/or have a way to start a new conversation. Something like: chatgpt --new-chat.

I just learned in the hard way how can be painful kept a large context in a loop.

Thx

kardolus commented 1 year ago

Thanks for your feedback! I have been struggling with this myself as well.

As a coincidence I was just about to release 1.2.0 when I read this.

In this release I introduced a three tier configuration strategy in which environment variables take precedence over a user provided config.yaml, which in turn takes precedence over default values.

Long story short, you can now use OPENAI_OMIT_HISTORY (or update the config.yaml) in order to turn off any sort of history reading/writing. Example:

cat README.md | OPENAI_OMIT_HISTORY=true chatgpt give me the tldr

Just in case you were not aware yet, there's also the --clear-history flag which removes your local history.

Here's the documentation of the new configuration: https://github.com/kardolus/chatgpt-cli#configuration

Please let me know what you think!

kardolus commented 1 year ago

I'm also thinking about adding chat_name as a configuration option. In this way you can have per chat history like you do on the website.

andreaganduglia commented 1 year ago

It's great thanks!

IMHO the best way to managed this it allow users to point a specific history file as parameter.

chatgpt --historyfile /some/path/history.json

In that way, user can manage multiple conversation or point to /dev/null to avoid history in CLI fashion way. A default history path could be setup in the config.yaml file.

Anyway, nice work! I'm using it on all my devices, even on UserLand!

kardolus commented 1 year ago

Thanks for the kind words and the feedback! I'm stoked that you're using the CLI.

I will try to find some time later today or in the weekend to work on the chat_name (I think I will call this thread). I was thinking of having the CLI automatically manage the message history for each "thread" you converse with. The thread-name being configurable.

When I introduce this, I will likely need a little migration method in order to support this new structure:

~/.chatgpt-cli/history/default.json
~/.chatgpt-cli/history/my-thread.json
etc.

I went with a 3 tier configuration model (environment > config.yaml > defaults). I may introduce those flags you mentioned as well. In that case it would be 4 tier: (flags > environment > config.yaml > defaults). I will need to think about that for a bit to see if it makes sense from a UX perspective. I like to keep things simple, but perhaps having flags is fine.

kardolus commented 1 year ago

Just released 1.3.0 with support for per thread context :). Closing this issue for now. Please feel free to reopen or make a new one.

acro5piano commented 9 months ago

Let me share my experience.

I had an inverted issue. My issue was the chat history was not saved, meaning ChatGPT didn't preserve any contents. The reason was that directory $HOME/.chatgpt-cli was missing for some reason.

$ chatgpt --clear-history

stat /home/kazuya/.chatgpt-cli: no such file or directory

Then I created the directory and my issue was gone.

mkdir $HOME/.chatgpt-cli

Hope this helps someone. Thank you for the great tool!

kardolus commented 9 months ago

Thanks @acro5piano! In the current version of the CLI (1.3.3), the directory should no longer be removed:

± |main ✓| →  chatgpt --clear-history
History successfully cleared.

± |main ✓| → stat $HOME/.chatgpt-cli
16777232 22380009 drwxr-xr-x 4 gkardolus staff 0 128 "Jul 10 15:47:17 2023" "Jul 10 15:32:56 2023" "Jul 10 15:32:56 2023" "May  4 02:49:41 2023" 4096 0 0 /Users/kardolus/.chatgpt-cli

Thanks for sharing your feedback!