Compare commits

...

6 Commits

Author SHA1 Message Date
0xacx
5d8dcb6ae5
Merge pull request #13 from 0xacx/add-model-retrieval
Add colors to json response
2023-02-08 21:53:05 +02:00
acx
b0400fc4ca Add colors to json response 2023-02-08 21:52:26 +02:00
0xacx
cf45c6010c
Update README.md 2023-02-08 20:39:37 +02:00
0xacx
b4bbb56f27
Update README.md 2023-02-08 20:38:09 +02:00
0xacx
f11493c0a6
Merge pull request #12 from 0xacx/add-model-retrieval
Add model retrieval and complete view commands
2023-02-08 20:30:45 +02:00
acx
7a7434ffa0 Add model retrieval and complete view commands 2023-02-08 20:26:08 +02:00
2 changed files with 18 additions and 1 deletions

View File

@ -10,6 +10,7 @@ The script uses the `completions` endpoint and the `text-davinci-003` model for
- Chat with GPT from the terminal
- Generate images from a text prompt
- View your chat history
- List all available OpenAI models
![Screenshot 2023-01-12 at 13 59 08](https://user-images.githubusercontent.com/99351112/212061157-bc92e221-ad29-46b7-a0a8-c2735a09449d.png)
@ -41,7 +42,7 @@ This script relies on curl for the requests to the api and jq to parse the json
### Manual Installation
If want to install it manually, all you have to do is:
If you want to install it manually, all you have to do is:
- Download the `chatgpt.sh` file in a directory you want
- Add the path of `chatgpt.sh` to your `$PATH`. You do that by adding this line to your shell profile: `export PATH=$PATH:/path/to/chatgpt.sh`
@ -54,4 +55,6 @@ This script relies on curl for the requests to the api and jq to parse the json
- To generate images, start a prompt with `image:`
If you are using iTerm, you can view the image directly in the terminal. Otherwise the script will ask to open the image in your browser.
- To view your chat history, type `history`
- To get a list of the models available at OpenAI API, type `models`
- To view all the information on a specific model, use `model:` and the model `id` as it appears in the list of models. For example: `model:text-babbage:001` will get you all the fields for `text-babbage:001` model

View File

@ -52,6 +52,20 @@ while $running; do
fi
elif [[ "$prompt" == "history" ]]; then
echo -e "\n$(cat ~/.chatgpt_history)"
elif [[ "$prompt" == "models" ]]; then
models_response=$(curl https://api.openai.com/v1/models \
-sS \
-H "Authorization: Bearer $OPENAI_KEY")
handleError "$models_response"
models_data=$(echo $models_response | jq -r -C '.data[] | {id, owned_by, created}')
echo -e "\n\033[36mchatgpt \033[0m This is a list of models currently available at OpenAI API:\n ${models_data}"
elif [[ "$prompt" =~ ^model: ]]; then
models_response=$(curl https://api.openai.com/v1/models \
-sS \
-H "Authorization: Bearer $OPENAI_KEY")
handleError "$models_response"
model_data=$(echo $models_response | jq -r -C '.data[] | select(.id=="'"${prompt#*model:}"'")')
echo -e "\n\033[36mchatgpt \033[0m Complete data for model: ${prompt#*model:}\n ${model_data}"
else
# escape quotation marks
escaped_prompt=$(echo "$prompt" | sed 's/"/\\"/g')