Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Change-Id: If09a99b8f4637bae509b32469b0cd9fd9ec60024
  • Loading branch information
MarkDaoust committed Jul 23, 2024
1 parent 84b1a9e commit eb02d25
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions samples/rest/caching.sh → samples/rest/cache.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
set -eu

if [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
B64FLAGS="--input"
else
B64FLAGS="-w0"
fi

echo "[START cache_create]"
# [START cache_create]
wget https://storage.googleapis.com/generativeai-downloads/data/a11.txt
Expand All @@ -11,7 +17,7 @@ echo '{
{
"inline_data": {
"mime_type":"text/plain",
"data": "'$(base64 -w0 a11.txt)'"
"data": "'$(base64 $B64FLAGS a11.txt)'"
}
}
],
Expand Down Expand Up @@ -56,8 +62,7 @@ rm a11.txt request.json

echo "[START cache_list]"
# [START cache_list]
ALL_CACHES=$(curl "https://generativelanguage.googleapis.com/v1beta/cachedContents?key=$GOOGLE_API_KEY")
CACHE_NAME=$(echo "$ALL_CACHES" | grep '"name":' | cut -d '"' -f 4 | head -n 1)
curl "https://generativelanguage.googleapis.com/v1beta/cachedContents?key=$GOOGLE_API_KEY"
# [END cache_list]

echo "[START cache_get]"
Expand Down

0 comments on commit eb02d25

Please sign in to comment.