@@ -67,50 +67,50 @@ ask_chatgpt() {
67
67
GPT_RESPONSE_=" ${COL7_} "
68
68
GPT_INPUT_FILE_=" $( basename " ${SCRIPT_PATH_TMP_} " ) "
69
69
70
- print_output " [*]trying to check inside ${LOG_DIR} /firmware" " no_log"
70
+ print_output " [*] Trying to check inside ${ORANGE}${ LOG_DIR} /firmware${NC} " " no_log"
71
71
SCRIPT_PATH_TMP_=" $( find " ${LOG_DIR} /firmware" -wholename " *${SCRIPT_PATH_TMP_} " ) "
72
72
cp " ${SCRIPT_PATH_TMP_} " " ${GPT_FILE_DIR_} /${GPT_INPUT_FILE_} .log"
73
- print_output " [*]trying to check ${SCRIPT_PATH_TMP_} with Question ${GPT_QUESTION_} " " no_log"
73
+ print_output " [*] Trying to check ${ORANGE} ${ SCRIPT_PATH_TMP_} ${NC} with Question ${ORANGE}${ GPT_QUESTION_}${NC} " " no_log"
74
74
print_output " [*]Prio is ${GPT_PRIO_} " " no_log"
75
75
76
76
if [[ -z ${GPT_ANSWER_} ]] && [[ ${GPT_PRIO_} -le ${MINIMUM_GPT_PRIO} ]]; then
77
77
if [ -f " ${SCRIPT_PATH_TMP_} " ]; then
78
78
# add navbar-item for file
79
79
sub_module_title " ${GPT_INPUT_FILE_} "
80
- print_output " [*] Asking ChatGPT about $( print_path " ${SCRIPT_PATH_TMP_} " ) " " " " ${GPT_FILE_DIR_} /${GPT_INPUT_FILE_} .log"
80
+ print_output " [*] Asking ChatGPT about ${ORANGE} $ ( print_path " ${SCRIPT_PATH_TMP_} " ) ${NC} " " " " ${GPT_FILE_DIR_} /${GPT_INPUT_FILE_} .log"
81
81
head -n -2 " ${CONFIG_DIR} /gpt_template.json" > " ${TMP_DIR} /chat.json"
82
82
CHATGPT_CODE_=$( sed ' s/\\//g;s/"/\\\"/g' " ${SCRIPT_PATH_TMP_} " | tr -d ' [:space:]' )
83
83
printf ' "%s %s"\n}]}' " ${GPT_QUESTION_} " " ${CHATGPT_CODE_} " >> " ${TMP_DIR} /chat.json"
84
- print_output " [*] The Combined Cost of the OpenAI request / the length is: ${# GPT_QUESTION_} + ${# CHATGPT_CODE_} " " no_log"
84
+ print_output " [*] The Combined Cost of the OpenAI request / the length is: ${ORANGE}${ # GPT_QUESTION_} + ${# CHATGPT_CODE_}${NC } " " no_log"
85
85
HTTP_CODE_=$( curl https://api.openai.com/v1/chat/completions -H " Content-Type: application/json" \
86
86
-H " Authorization: Bearer ${OPENAI_API_KEY} " \
87
- -d @" ${TMP_DIR} /chat.json" -o " ${TMP_DIR} /response .json" --write-out " %{http_code}" )
87
+ -d @" ${TMP_DIR} /chat.json" -o " ${TMP_DIR} /${GPT_INPUT_FILE_} _response .json" --write-out " %{http_code}" )
88
88
if [[ " ${HTTP_CODE_} " -ne 200 ]] ; then
89
89
print_output " [-] Something went wrong with the ChatGPT requests"
90
- if [ -f " ${TMP_DIR} /response .json" ]; then
91
- print_output " [-] ERROR response:$( cat " ${TMP_DIR} /response .json" ) "
90
+ if [ -f " ${TMP_DIR} /${GPT_INPUT_FILE_} _response .json" ]; then
91
+ print_output " [-] ERROR response:$( cat " ${TMP_DIR} /${GPT_INPUT_FILE_} _response .json" ) "
92
92
fi
93
- if jq ' .error.type' " ${TMP_DIR} " /response .json | grep -q " insufficient_quota" ; then
93
+ if jq ' .error.type' " ${TMP_DIR} / ${GPT_INPUT_FILE_} _response .json" | grep -q " insufficient_quota" ; then
94
94
CHATGPT_RESULT_CNT=-1
95
95
break 2
96
96
fi
97
97
fi
98
- GPT_RESPONSE_=$( jq ' .choices[] | .message.content' " ${TMP_DIR} " /response .json)
98
+ GPT_RESPONSE_=$( jq ' .choices[] | .message.content' " ${TMP_DIR} / ${GPT_INPUT_FILE_} _response .json" )
99
99
GPT_RESPONSE_CLEANED_=" ${GPT_RESPONSE_// \; / } " # remove ; from response
100
- GPT_TOKENS_=$( jq ' .usage.total_tokens' " ${TMP_DIR} " /response .json)
100
+ GPT_TOKENS_=$( jq ' .usage.total_tokens' " ${TMP_DIR} / ${GPT_INPUT_FILE_} _response .json" )
101
101
if [[ ${GPT_TOKENS_} -ne 0 ]]; then
102
102
# write new into done csv
103
103
write_csv_gpt " ${GPT_INPUT_FILE_} " " ${GPT_ANCHOR_} " " GPT-Prio-${GPT_PRIO_} " " ${GPT_QUESTION_} " " ${GPT_OUTPUT_FILE_} " " cost=${GPT_TOKENS_} " " '${GPT_RESPONSE_CLEANED_// \' / } '"
104
104
# print openai response
105
105
print_output " CHATGPT:${GPT_RESPONSE_// \" / } "
106
106
# add proper module link
107
- print_output " [+] Further results available for $GPT_INPUT_FILE_ "
107
+ print_output " [+] Further results available for ${ORANGE}${ GPT_INPUT_FILE_}${NC} "
108
108
ORIGIN_MODULE_=" $( basename " $( dirname " ${GPT_OUTPUT_FILE_} " ) " | cut -d_ -f1) "
109
109
write_link " ${ORIGIN_MODULE_} "
110
110
(( CHATGPT_RESULT_CNT++ ))
111
111
fi
112
112
else
113
- print_output " [-] Couldn't find $( print_path " ${SCRIPT_PATH_TMP_} " ) "
113
+ print_output " [-] Couldn't find ${ORANGE} $ ( print_path " ${SCRIPT_PATH_TMP_} " ) ${NC} "
114
114
fi
115
115
fi
116
116
if [[ " ${GPT_OPTION} " -ne 2 ]]; then
0 commit comments