File size: 1,573 Bytes
20c7340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/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