Skip to content

Commit c038c60

Browse files
committed
use stdin input to prevent curl too long argument
1 parent 43966fc commit c038c60

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
gemini_api_key.txt
22
chat_history.txt
3+
payload.json

gemini.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ while true; do
106106
}
107107
"
108108

109-
response=$(curl -s "$API_URL" -H "Content-Type: application/json" -d "$request_body")
109+
# NOTE: using the stdin input to prevent curl too long argument list size
110+
response=$(curl -s "$API_URL" -H "Content-Type: application/json" --data-binary @- << EOF
111+
$request_body
112+
EOF
113+
)
110114

111115
text=$(echo "$response" | jq -r '.candidates[0].content.parts[0].text')
112116
echo -e "====================\n"

0 commit comments

Comments
 (0)