Skip to content

Commit c6556b8

Browse files
committed
'cleanup'
1 parent 4bc87f2 commit c6556b8

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

ollama_bash_lib.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ _debug() {
5353
(( OLLAMA_LIB_DEBUG )) || return 0 # DEBUG must be 1 or higher to show debug messages
5454
local date_string # some date implementations do not support %N nanoseconds
5555
date_string="$(if ! date '+%H:%M:%S:%N' 2>/dev/null; then date '+%H:%M:%S'; fi)"
56-
printf "[DEBUG] ${date_string}: %s\n" "$(_redact "$1")" >&2
56+
printf '[DEBUG] %s: %s\n' "$date_string" "$(_redact "$1")" >&2
5757
}
5858

5959
# Error message
@@ -64,7 +64,7 @@ _debug() {
6464
# Requires: none
6565
# Returns: 0 on success, 1 on error
6666
_error() {
67-
printf "[ERROR] %s\n" "$(_redact "$1")" >&2
67+
printf '[ERROR] %s\n' "$(_redact "$1")" >&2
6868
}
6969

7070
# Does a command exist?
@@ -702,10 +702,10 @@ EOF
702702
_ollama_thinking_stream() {
703703
local chunk
704704
if read -r -n 1 chunk && [[ -n "$chunk" ]]; then
705-
printf "#### <thinking>\n" >&2
706-
printf "#### %s" "$chunk" >&2
705+
printf '#### <thinking>\n' >&2
706+
printf '#### %s' "$chunk" >&2
707707
cat >&2
708-
printf "\n#### </thinking>\n\n" >&2
708+
printf '\n#### </thinking>\n\n' >&2
709709
fi
710710
}
711711

@@ -914,7 +914,7 @@ EOF
914914
_debug "ollama_messages_add: [${role:0:42}] [${content:0:42}]"
915915

916916
local json_payload
917-
if [[ "$role" == "tool" ]]; then
917+
if [[ "$role" == 'tool' ]]; then
918918
if ! _is_valid_json "$content"; then
919919
_error 'ollama_messages_add: for "tool" role, content must be a valid JSON'
920920
return 1
@@ -1166,7 +1166,6 @@ _ollama_chat_stream_false() {
11661166
ollama_messages_add -r 'assistant' -c "$content"
11671167
_debug "_ollama_chat_stream_false: ollama_messages_count: [$(ollama_messages_count)]"
11681168

1169-
#echo "$result"
11701169
_debug '_ollama_chat_stream_false: success'
11711170
return 0
11721171
}
@@ -1175,7 +1174,7 @@ _ollama_chat_payload() {
11751174
local model="$1"
11761175

11771176
local stream=true
1178-
if [[ "$OLLAMA_LIB_STREAM" -eq "0" ]]; then
1177+
if [[ "$OLLAMA_LIB_STREAM" -eq '0' ]]; then
11791178
stream=false
11801179
fi
11811180

@@ -1188,7 +1187,7 @@ _ollama_chat_payload() {
11881187
messages_json='['$(IFS=,; echo "${OLLAMA_LIB_MESSAGES[*]}")']'
11891188

11901189
local thinking=true
1191-
if [[ "$OLLAMA_LIB_THINKING" == "off" ]]; then
1190+
if [[ "$OLLAMA_LIB_THINKING" == 'off' ]]; then
11921191
thinking=false
11931192
fi
11941193

@@ -1386,7 +1385,7 @@ EOF
13861385
OLLAMA_LIB_STREAM=1
13871386
(
13881387
ollama_chat -m "$model" | while IFS= read -r line; do
1389-
if [[ "$OLLAMA_LIB_THINKING" == "on" ]]; then
1388+
if [[ "$OLLAMA_LIB_THINKING" == 'on' ]]; then
13901389
printf '%s' "$(jq -r '.thinking // empty' <<<"$line")" >&2
13911390
fi
13921391
read -r -d '' content < <(jq -r '.message.content // empty' <<<"$line")
@@ -1792,7 +1791,7 @@ EOF
17921791
local command
17931792
command="${OLLAMA_LIB_TOOLS_COMMAND[$tool_index]}"
17941793

1795-
if [[ -z "$tool_args_str" ]] || [[ "$tool_args_str" == "null" ]]; then
1794+
if [[ -z "$tool_args_str" ]] || [[ "$tool_args_str" == 'null' ]]; then
17961795
tool_args_str="{}"
17971796
fi
17981797

0 commit comments

Comments
 (0)