-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_interactive.sh
More file actions
executable file
·222 lines (197 loc) · 7.45 KB
/
run_interactive.sh
File metadata and controls
executable file
·222 lines (197 loc) · 7.45 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/bin/bash
# Interactive AIQ Agent Runner
# Provides a menu-driven interface for running AI queries
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m'
# Configuration
CONFIG_FILE="workflow.yaml"
ENV_FILE=".env"
# Function to display banner
show_banner() {
echo -e "${CYAN}╔═══════════════════════════════════════╗${NC}"
echo -e "${CYAN}║ AIQ Agent Interactive ║${NC}"
echo -e "${CYAN}║ Query Interface ║${NC}"
echo -e "${CYAN}╚═══════════════════════════════════════╝${NC}"
echo ""
}
# Function to display main menu
show_menu() {
echo -e "${BLUE}Choose an option:${NC}"
echo -e " ${GREEN}1${NC}) Ask a custom question"
echo -e " ${GREEN}2${NC}) Quick queries (pre-defined questions)"
echo -e " ${GREEN}3${NC}) Configuration settings"
echo -e " ${GREEN}4${NC}) Help & Examples"
echo -e " ${GREEN}5${NC}) Exit"
echo ""
}
# Function to display quick queries menu
show_quick_queries() {
echo -e "${PURPLE}Quick Query Options:${NC}"
echo -e " ${GREEN}1${NC}) Animal facts (e.g., subspecies of animals)"
echo -e " ${GREEN}2${NC}) Scientific information"
echo -e " ${GREEN}3${NC}) Historical facts"
echo -e " ${GREEN}4${NC}) Technology questions"
echo -e " ${GREEN}5${NC}) General knowledge"
echo -e " ${GREEN}6${NC}) Back to main menu"
echo ""
}
# Function to get animal fact questions
get_animal_question() {
echo -e "${YELLOW}Animal Fact Categories:${NC}"
echo "1) Subspecies information"
echo "2) Habitat and behavior"
echo "3) Conservation status"
echo "4) Evolutionary history"
echo ""
read -p "Select category (1-4): " category
case $category in
1) read -p "Enter animal name for subspecies info: " animal
QUESTION="List the subspecies of $animal and their characteristics" ;;
2) read -p "Enter animal name for habitat info: " animal
QUESTION="Describe the habitat and behavior of $animal" ;;
3) read -p "Enter animal name for conservation info: " animal
QUESTION="What is the conservation status of $animal and what threats do they face?" ;;
4) read -p "Enter animal name for evolution info: " animal
QUESTION="Describe the evolutionary history of $animal" ;;
*) echo -e "${RED}Invalid selection${NC}"; return 1 ;;
esac
}
# Function to run the agent with error handling
run_agent() {
local question="$1"
echo -e "${GREEN}Running query: ${YELLOW}$question${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
if [[ -f "$ENV_FILE" ]]; then
uv run --env-file "$ENV_FILE" aiq run --config_file "$CONFIG_FILE" --input "$question"
else
echo -e "${YELLOW}Warning: $ENV_FILE not found, using environment variables${NC}"
uv run aiq run --config_file "$CONFIG_FILE" --input "$question"
fi
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
}
# Function to show configuration
show_config() {
echo -e "${PURPLE}Current Configuration:${NC}"
echo "Config file: $CONFIG_FILE"
echo "Environment file: $ENV_FILE"
echo ""
if [[ -f "$ENV_FILE" ]]; then
echo -e "${GREEN}✓ Environment file found${NC}"
else
echo -e "${RED}✗ Environment file not found${NC}"
fi
if [[ -f "$CONFIG_FILE" ]]; then
echo -e "${GREEN}✓ Config file found${NC}"
else
echo -e "${RED}✗ Config file not found${NC}"
fi
echo ""
read -p "Press Enter to continue..."
}
# Function to show help and examples
show_help() {
echo -e "${PURPLE}Help & Examples:${NC}"
echo ""
echo -e "${YELLOW}Example Questions:${NC}"
echo "• List five subspecies of elephants"
echo "• What are the main causes of climate change?"
echo "• Explain quantum computing in simple terms"
echo "• Who were the key figures in the Renaissance?"
echo "• How does machine learning work?"
echo ""
echo -e "${YELLOW}Tips:${NC}"
echo "• Be specific in your questions for better results"
echo "• The agent can search Wikipedia for factual information"
echo "• Complex questions may take longer to process"
echo ""
read -p "Press Enter to continue..."
}
# Main interactive loop
main() {
show_banner
# Check if files exist
if [[ ! -f "$CONFIG_FILE" ]]; then
echo -e "${RED}Error: Config file '$CONFIG_FILE' not found${NC}"
exit 1
fi
while true; do
show_menu
read -p "Enter your choice (1-5): " choice
echo ""
case $choice in
1)
read -p "Enter your question: " QUESTION
if [[ -n "$QUESTION" ]]; then
run_agent "$QUESTION"
echo ""
read -p "Press Enter to continue..."
fi
;;
2)
show_quick_queries
read -p "Enter your choice (1-6): " quick_choice
echo ""
case $quick_choice in
1)
if get_animal_question; then
run_agent "$QUESTION"
read -p "Press Enter to continue..."
fi
;;
2)
read -p "Enter scientific topic: " topic
QUESTION="Explain $topic and its key principles"
run_agent "$QUESTION"
read -p "Press Enter to continue..."
;;
3)
read -p "Enter historical period/event: " event
QUESTION="Provide detailed information about $event"
run_agent "$QUESTION"
read -p "Press Enter to continue..."
;;
4)
read -p "Enter technology topic: " tech
QUESTION="Explain how $tech works and its applications"
run_agent "$QUESTION"
read -p "Press Enter to continue..."
;;
5)
read -p "Enter your general knowledge question: " QUESTION
run_agent "$QUESTION"
read -p "Press Enter to continue..."
;;
6)
continue
;;
*)
echo -e "${RED}Invalid selection${NC}"
;;
esac
;;
3)
show_config
;;
4)
show_help
;;
5)
echo -e "${GREEN}Thank you for using AIQ Agent Interactive!${NC}"
exit 0
;;
*)
echo -e "${RED}Invalid choice. Please select 1-5.${NC}"
;;
esac
echo ""
done
}
# Run main function
main