Last active
August 23, 2024 20:27
-
-
Save chenasraf/12c3bc607a0d46d99e77c6538d20a424 to your computer and use it in GitHub Desktop.
Ollama CLI prompt
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
#!/usr/bin/env bash | |
ollama_prompt() { | |
prompt="$@" | |
endpoint="http://localhost:11434" | |
curl $endpoint/api/generate -XPOST \ | |
--no-buffer \ | |
-s \ | |
-H 'Content-Type: application/json' \ | |
-d '{"prompt":"'$prompt'","model":"llama3.1"}' | \ | |
while IFS= read -r line; do | |
line="${line//$'\\n'/\\\\n}" | |
response="$(printf '%s\n' "$line" | jq -r '.response')" | |
echo -n "$response" | |
done | |
echo | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment