File size: 1,487 Bytes
2043365
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Ollama model download
set -e

echo "πŸš€ Setting up Ollama for Text Summarizer Backend..."

# Check if Ollama is running
if ! curl -s http://localhost:11434/api/tags > /dev/null; then
    echo "❌ Ollama is not running. Please start Ollama first:"
    echo "   docker-compose up ollama -d"
    echo "   or"
    echo "   ollama serve"
    exit 1
fi

# Default model
MODEL=${1:-"llama3.1:8b"}

echo "πŸ“₯ Downloading model: $MODEL"
echo "This may take several minutes depending on your internet connection..."

# Pull the model
ollama pull "$MODEL"

echo "βœ… Model $MODEL downloaded successfully!"

# Test the model
echo "πŸ§ͺ Testing model..."
TEST_RESPONSE=$(curl -s -X POST http://localhost:11434/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "model": "'"$MODEL"'",
    "prompt": "Summarize this: Hello world",
    "stream": false
  }')

if echo "$TEST_RESPONSE" | grep -q "response"; then
    echo "βœ… Model test successful!"
else
    echo "❌ Model test failed. Response:"
    echo "$TEST_RESPONSE"
    exit 1
fi

echo ""
echo "πŸŽ‰ Setup complete! Your text summarizer backend is ready to use."
echo ""
echo "Next steps:"
echo "1. Start the API: docker-compose up api -d"
echo "2. Test the API: curl http://localhost:8000/health"
echo "3. Try summarization: curl -X POST http://localhost:8000/api/v1/summarize/ \\"
echo "   -H 'Content-Type: application/json' \\"
echo "   -d '{\"text\": \"Your text to summarize here...\"}'"