#!/bin/bash # Define the prompt as a multi-line variable read -r -d '' PROMPT << 'EOF' Please analyze this text and rate its sentiment on a scale from -10 (very negative) to +10 (very positive). Provide your rating as a numeric score and as human-readable text. Explain your rating: EOF if ! command -v llm &> /dev/null; then echo "llm could not be found, you'll need to install it to use this program" exit 1 fi if ! command -v w3m &> /dev/null; then echo "w3m could not be found, you'll need to install it to use this program" exit 1 fi if ! command -v ollama &> /dev/null; then echo "ollama could not be found, you'll need to install it to use this program" exit 1 fi if ! ollama list | grep -q "llama3.1:8b"; then echo "ollama is not running, you'll need to start it to use this program" exit 1 fi if [ -z "$1" ]; then echo "Usage: ./sentiment [model]" exit 1 fi # Check if a model name is provided MODEL_OPTION="" if [ ! -z "$2" ]; then MODEL_OPTION="-m $2" fi w3m -dump "$1" | llm $MODEL_OPTION "$PROMPT"