0xacx / chatGPT-shell-cli

Simple shell script to use OpenAI's ChatGPT and DALL-E from the terminal. No Python or JS required.
https://gptshell.cc
MIT License
1.11k stars 157 forks source link

Need non-interactive mode #46

Open ecsplendid opened 1 year ago

ecsplendid commented 1 year ago
cat parts000.txt | chatgpt --model gpt-4 --max-tokens 10

I want the program to exit and not hang

image
0xacx commented 1 year ago

Hm, that's an interesting edge case.

First, you don't need the prompt flag -p, when you pass the prompt through pipe.

The code hangs because the script part that handles the gpt-3.5-turbo and gpt-4 models, is designed to only work with conversational context, meaning sending back every question and answer to the model, so it can remember the previous messages. As a result it expects the max tokens to be set to at least 100. When you set a limit lower than that, the loop that trims the prompt length hangs. I will have to think the best way to handle this and get back to it. Meanwhile if you need to run something with low token limit, you can try all the other models except gpt-3.5-turbo and gpt-4. The other models do not maintain conversational context by default, only if set (--chat-context or -c flag).