Created
October 21, 2024 04:27
-
-
Save saahityaedams/d0a94380d5670b465a6e627f5e23ea26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # wrapper for calling LLM with an image | |
| # eg. make_moondream_ollama_request /tmp/out.jpeg "is the image black and white ? " | |
| # eg. make_moondream_ollama_request /tmp/out.jpeg | |
| make_moondream_ollama_request() { | |
| local file_path=$1 | |
| local model="moondream" | |
| local prompt=${2:-"Describe the image?"} | |
| local api_url="http://localhost:11434/api/generate" | |
| # Generate base64 string without newlines | |
| base64_string=$(base64 -w 0 "$file_path") | |
| # Perform the curl request | |
| curl -s "$api_url" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "model": "'"$model"'", | |
| "prompt": "'"$prompt"'", | |
| "stream": false, | |
| "images": ["'"$base64_string"'"] | |
| }' | jq .response | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO