lexsg / setup_ollama_model.sh
sausheong's picture
Upload 4 files
20c7340 verified
#!/bin/bash
# Setup script for importing the Singapore Statutes model into Ollama
MODEL_NAME="lexsg"
MODELFILE_PATH="./Modelfile"
echo "πŸš€ Setting up LexSG model in Ollama..."
echo "Model name: $MODEL_NAME"
echo "Modelfile: $MODELFILE_PATH"
echo ""
# Check if Ollama is installed
if ! command -v ollama &> /dev/null; then
echo "❌ Ollama is not installed. Please install Ollama first:"
echo " curl -fsSL https://ollama.ai/install.sh | sh"
exit 1
fi
# Check if Ollama service is running
if ! pgrep -x "ollama" > /dev/null; then
echo "⚠️ Ollama service is not running. Starting Ollama..."
ollama serve &
sleep 3
fi
# Import the model
echo "πŸ“¦ Creating model from Modelfile..."
ollama create $MODEL_NAME -f $MODELFILE_PATH
if [ $? -eq 0 ]; then
echo ""
echo "βœ… SUCCESS! Model '$MODEL_NAME' has been created in Ollama."
echo ""
echo "πŸ”§ Usage examples:"
echo " # Start a chat session"
echo " ollama run $MODEL_NAME"
echo ""
echo " # Ask a specific question"
echo " ollama run $MODEL_NAME \"What does the Personal Data Protection Act cover?\""
echo ""
echo " # Use via API"
echo " curl http://localhost:11434/api/generate -d '{"
echo " \"model\": \"$MODEL_NAME\","
echo " \"prompt\": \"Explain Section 1 of the Companies Act\","
echo " \"stream\": false"
echo " }'"
echo ""
echo "πŸ“‹ Model information:"
ollama show $MODEL_NAME
else
echo "❌ Failed to create model. Please check the Modelfile and try again."
exit 1
fi