Skip to content

Commit

Permalink
Fixup prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Dec 6, 2024
1 parent 9a712fa commit 978f578
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
4 changes: 2 additions & 2 deletions examples/openai-htr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ SHELL ["/bin/ash", "-o", "pipefail", "-c"]
# hadolint ignore=DL3018
RUN --mount=type=bind,from=imagemagick,source=/packages,target=/packages \
--mount=type=bind,from=imagemagick,source=/etc/apk/keys,target=/etc/apk/keys \
apk add --no-cache /packages/imagemagick-*.apk
apk add --no-cache /packages/imagemagick-*.apk jq==1.7.1-r0

RUN magick -list format | grep "JPEG-2000"

ENV OPENAI_MODEL=gpt-4o-mini \
PROMPT="Transcribe this image that contains handwritten text. Include all text you see in the image. In your response, say absolutely nothing except the text from the image" \
PROMPT="Transcribe this image that contains handwritten text. Include all text you see in the image. In your response, say absolutely nothing except the text from the image." \
MAX_TOKENS=300

COPY scyllaridae.yml /app/scyllaridae.yml
Expand Down
50 changes: 28 additions & 22 deletions examples/openai-htr/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@ magick - "$TMP_DIR/img.jpg"

BASE64_IMAGE=$(base64 -w 0 "$TMP_DIR/img.jpg")

curl https://api.openai.com/v1/chat/completions \
cat <<EOF > "$TMP_DIR/payload.json"
{
"model": "$OPENAI_MODEL",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "$PROMPT"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,$BASE64_IMAGE"
}
}
]
}
],
"max_tokens": $MAX_TOKENS
}
EOF

curl -s https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "'"$OPENAI_MODEL"'",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "'"$PROMPT"'"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,'"$BASE64_IMAGE"'"
}
}
]
}
],
"max_tokens": '"$MAX_TOKENS"'
}' | jq -r .choices[0].message.content
-d "@$TMP_DIR/payload.json" | jq -r .choices[0].message.content

rm -rf "$TMP_DIR"

0 comments on commit 978f578

Please sign in to comment.