Merge pull request #13 from 0xacx/add-model-retrieval

Add colors to json response
This commit is contained in:
0xacx 2023-02-08 21:53:05 +02:00 committed by GitHub
commit 5d8dcb6ae5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,14 +57,14 @@ while $running; do
-sS \
-H "Authorization: Bearer $OPENAI_KEY")
handleError "$models_response"
models_data=$(echo $models_response | jq -r '.data[] | {id, owned_by, created}')
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 '.data[] | select(.id=="'"${prompt#*model:}"'")')
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