From 30852e57df1cd26ee1af64ee6752b0924520bd37 Mon Sep 17 00:00:00 2001 From: MrRaph_ Date: Mon, 17 Jun 2024 19:13:15 +0200 Subject: [PATCH] merged all Raycast Scripts --- .gitignore | 1 + AI/image-caption-and-hashtags.sh | 48 ++++++++++++++++++++++++++++++ AI/include.sh | 1 + Utils/global-protect.sh | 38 ++++++++++++++++++++++++ global-protect.sh | 50 -------------------------------- 5 files changed, 88 insertions(+), 50 deletions(-) create mode 100644 .gitignore create mode 100755 AI/image-caption-and-hashtags.sh create mode 100644 AI/include.sh create mode 100755 Utils/global-protect.sh delete mode 100755 global-protect.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..397b4a7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.log diff --git a/AI/image-caption-and-hashtags.sh b/AI/image-caption-and-hashtags.sh new file mode 100755 index 0000000..2721e3f --- /dev/null +++ b/AI/image-caption-and-hashtags.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Required parameters: +# @raycast.schemaVersion 1 +# @raycast.title Generate Instagram Caption and Hashtags for image +# @raycast.mode silent +# @raycast.packageName MrRaph_ AI +# +# Optional parameters: +# @raycast.icon 📸 +# +# Documentation: +# @raycast.description This script get selected image's path, generate caption and hashtags for it +# @raycast.author Jakub Lanski +# @raycast.authorURL https://github.com/jaklan + +imagePath=$(osascript -e 'tell application "Finder" + set selectedFiles to selection + if (count of selectedFiles) is 0 then + return "No file selected" + else + set selectedFile to item 1 of selectedFiles + set filePath to POSIX path of (selectedFile as text) + return filePath + end if + end tell') + +source $(dirname $0)/include.sh + +nl=$'\n' + +( + echo '<|begin_of_text|><|start_header_id|>system<|end_header_id|>' + echo "Give a short, accurate and fun caption for the picture. Give a list of 9 trending hashtags that suits with the given description. Give only the caption and hashtags list, don't say anything else. Output must be made in French. Based on following image description :" + $LLAMAFILES_PATH/llava-v1.5-7b-q4.llamafile --temp 0.2 --image "$imagePath" -e -p "### User: Describe the image as accurately and in as much detail as possible. Don't try to make up details or information you don't know. Don't hesitate to make a description as log as possible to best describe the picture.\n### Assistant:" --no-display-prompt 2>/dev/null + echo '<|eot_id|>{{history}}<|start_header_id|>{{char}}<|end_header_id|>' +) | $LLAMAFILES_PATH/Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile -ngl 9999 \ + -f /dev/stdin \ + -c 0 \ + --temp 0 \ + -n 500 \ + --no-display-prompt 2>/dev/null | sed 's/<|start_header_id|>assistant<|end_header_id|>//' | sed -r '/^\s*$/d' | sed 's/<|eot_id|>//' | sed 's/"//g' | sed '1 a\ +-\ +- +' | pbcopy + + +echo "Copied" \ No newline at end of file diff --git a/AI/include.sh b/AI/include.sh new file mode 100644 index 0000000..66ede4c --- /dev/null +++ b/AI/include.sh @@ -0,0 +1 @@ +export LLAMAFILES_PATH=/Users/mrraph/AI/llamafiles \ No newline at end of file diff --git a/Utils/global-protect.sh b/Utils/global-protect.sh new file mode 100755 index 0000000..c9dbbbc --- /dev/null +++ b/Utils/global-protect.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Required parameters: +# @raycast.schemaVersion 1 +# @raycast.title GP Stop Start +# @raycast.mode silent +# @raycast.packageName MrRaph_ +# +# Optional parameters: +# @raycast.icon 🌎 +# @raycast.argument1 { "type": "text", "placeholder": "stop/start" } +# +# Documentation: +# @raycast.description This script stops or starts Global Protect VPN +# @raycast.author MrRaph_ +# @raycast.authorURL https://git.mrraph.fr + + +case $1 in + start) + echo "Starting GlobalProtect..." + launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangpa.plist + launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangps.plist + echo "GP Started !" + ;; + stop) + echo "Stopping GlobalProtect..." + launchctl remove com.paloaltonetworks.gp.pangps + launchctl remove com.paloaltonetworks.gp.pangpa + echo "GP Stopped !" + ;; + *) + echo "'$1' is not a valid verb." + echo "Usage: $0 {start|stop}" + exit 2 + ;; +esac +;; \ No newline at end of file diff --git a/global-protect.sh b/global-protect.sh deleted file mode 100755 index ff3741a..0000000 --- a/global-protect.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -# Required parameters: -# @raycast.schemaVersion 1 -# @raycast.title GP Stop Start -# @raycast.mode silent -# @raycast.packageName MrRaph_ -# -# Optional parameters: -# @raycast.icon 🌎 -# @raycast.argument1 { "type": "text", "placeholder": "stop/start" } -# -# Documentation: -# @raycast.description This script stops or starts Global Protect VPN -# @raycast.author MrRaph_ -# @raycast.authorURL https://git.mrraph.fr - -case $# in - 0) - echo "Usage: $0 {start|stop}" - exit 1 - ;; - 1) - case $1 in - start) - echo "Starting GlobalProtect..." - launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangpa.plist - launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangps.plist - echo "GP Started !" - ;; - stop) - echo "Stopping GlobalProtect..." - launchctl remove com.paloaltonetworks.gp.pangps - launchctl remove com.paloaltonetworks.gp.pangpa - echo "GP Stopped !" - ;; - *) - echo "'$1' is not a valid verb." - echo "Usage: $0 {start|stop}" - exit 2 - ;; - esac - ;; - *) - echo "Too many args provided ($#)." - echo "Usage: $0 {start|stop}" - exit 3 - ;; -esac -