From c7b2e97aa1e4c1a3227e5295473849bfc9f55d2f Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Sun, 6 Aug 2023 14:26:35 +0700 Subject: [PATCH] Dry --- humanscript | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/humanscript b/humanscript index c8115fe..34da225 100755 --- a/humanscript +++ b/humanscript @@ -52,13 +52,14 @@ $(cat "${humanscript_path}") ### Output script:" # Format JSON payload -stringified_system_prompt=$(echo "${system_prompt}"| jq -sRr @json) -stringified_user_prompt=$(echo "${user_prompt}"| jq -sRr @json) +function json_string() { + echo "${1}" | jq --raw-input --raw-output --slurp @json +} data=$(echo '{ "model": "'$HUMANSCRIPT_MODEL'", "messages": [ - {"role": "system", "content": '$stringified_system_prompt'}, - {"role": "user", "content": '$stringified_user_prompt'} + {"role": "system", "content": '$(json_string "${system_prompt}")'}, + {"role": "user", "content": '$(json_string "${user_prompt}")'} ], "temperature": 0.7, "max_tokens": 1000,