Last active
April 17, 2023 23:02
-
-
Save jakkaj/218887771f70466e844dcbe082cd2ff6 to your computer and use it in GitHub Desktop.
Monitor a file, feed it to sgpt when it changes and store the output in a file. Allows for quick prompt iteration and stuff...
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
#!/bin/bash | |
#https://gist.github.com/jakkaj/218887771f70466e844dcbe082cd2ff6 | |
if [ -z "$OPENAI_API_KEY" ]; then | |
echo "The OPENAI_API_KEY environment variable is required and must not be empty." | |
exit 1 | |
fi | |
if ! command -v inotifywait >/dev/null 2>&1; then | |
echo "The 'inotifywait' command is not found. Please install it using the following command:" | |
echo "sudo apt-get install inotify-tools" | |
exit 1 | |
fi | |
if ! command -v sgpt >/dev/null 2>&1; then | |
echo "The 'sgpt' command is not found. Please visit https://github.com/TheR1D/shell_gpt to install it." | |
exit 1 | |
fi | |
if [ "$#" -lt 2 ] || [ "$#" -gt 4 ]; then | |
echo "Usage: $0 input_file output_file [temperature] [top_p]" | |
exit 1 | |
fi | |
input_file="$1" | |
output_file="$2" | |
temperature="${3:-0.1}" | |
top_p="${4:-1.0}" | |
inotifywait -q -m -e close_write --format "cat %w | sgpt --temperature $temperature --top-probability $top_p | tee $output_file" "$input_file" | sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment