-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_start.sh
More file actions
executable file
·134 lines (119 loc) · 3.92 KB
/
quick_start.sh
File metadata and controls
executable file
·134 lines (119 loc) · 3.92 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# Quick start script for Smart Inventory Watchdog Agent
# This script sets up and runs the complete system
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
echo "🚀 Smart Inventory Watchdog Agent - Quick Start"
echo "================================================"
echo ""
# Check if .env file exists
if [ ! -f ".env" ]; then
echo "⚠️ No .env file found. Creating from .env.example..."
if [ -f ".env.example" ]; then
cp .env.example .env
echo "✅ Created .env file. Please edit it with your configuration."
echo " Especially set your OPENAI_API_KEY"
exit 1
else
echo "❌ .env.example not found. Please create .env file manually."
exit 1
fi
fi
# Load environment variables
export $(cat .env | grep -v '^#' | xargs)
# Check if OpenAI API key is set
if [ -z "${OPENAI_API_KEY:-}" ]; then
echo "❌ Error: OPENAI_API_KEY not set in .env file"
exit 1
fi
# Step 1: Check if Docker is running
echo "🔍 Step 1: Checking Docker..."
if ! docker info > /dev/null 2>&1; then
echo "❌ Error: Docker is not running. Please start Docker and try again."
exit 1
fi
echo "✅ Docker is running"
# Step 2: Check if ecommerce microservice is running
echo ""
echo "🔍 Step 2: Checking ecommerce microservice..."
if ! curl -s http://localhost:8081/gilhari/v1/getObjectModelSummary/now > /dev/null; then
echo "⚠️ Ecommerce microservice is not running. Starting it..."
./setup_docker.sh
if [ $? -ne 0 ]; then
echo "❌ Failed to start ecommerce microservice"
exit 1
fi
else
echo "✅ Ecommerce microservice is running"
fi
# Step 3: Check if ORMCP server is running
echo ""
echo "🔍 Step 3: Checking ORMCP server..."
if ! curl -s http://localhost:8080/mcp/ > /dev/null 2>&1; then
echo "⚠️ ORMCP server is not running."
echo " Please start it in a separate terminal:"
echo " ./start_ormcp.sh"
echo ""
echo " Or run it in the background:"
echo " ./start_ormcp.sh &"
echo ""
read -p "Press Enter after starting ORMCP server, or Ctrl+C to exit..."
else
echo "✅ ORMCP server is running"
fi
# Step 4: Install Python dependencies
echo ""
echo "🔍 Step 4: Checking Python dependencies..."
if ! python3 -c "import langchain" 2>/dev/null; then
echo "⚠️ Python dependencies not installed. Installing..."
pip install -r requirements.txt
if [ $? -ne 0 ]; then
echo "❌ Failed to install dependencies"
exit 1
fi
else
echo "✅ Python dependencies are installed"
fi
# Step 5: Run the agent
echo ""
echo "🚀 Step 5: Starting Inventory Watchdog Agent..."
echo ""
# Determine mode
MODE="${1:-check}"
case "$MODE" in
check)
echo "Running single inventory check..."
python3 inventory_agent.py \
--openai-api-key "$OPENAI_API_KEY" \
--ormcp-url http://localhost:8080 \
--threshold "${DEFAULT_THRESHOLD:-50}" \
${ADMIN_EMAILS:+--admin-emails $ADMIN_EMAILS}
;;
monitor)
echo "Running continuous monitoring..."
python3 inventory_agent.py \
--openai-api-key "$OPENAI_API_KEY" \
--ormcp-url http://localhost:8080 \
--monitor \
--interval 3600 \
--threshold "${DEFAULT_THRESHOLD:-50}" \
${ADMIN_EMAILS:+--admin-emails $ADMIN_EMAILS}
;;
interactive)
echo "Running in interactive chat mode..."
python3 inventory_agent.py \
--openai-api-key "$OPENAI_API_KEY" \
--ormcp-url http://localhost:8080 \
--interactive
;;
*)
echo "Usage: $0 [check|monitor|interactive]"
echo ""
echo "Modes:"
echo " check - Run a single inventory check (default)"
echo " monitor - Run continuous monitoring"
echo " interactive - Run in interactive chat mode"
exit 1
;;
esac