-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_bot.sh
More file actions
172 lines (152 loc) · 4.83 KB
/
run_bot.sh
File metadata and controls
172 lines (152 loc) · 4.83 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
#!/bin/bash
# Function to clear screen
clear_screen() {
clear
}
# Function to show main menu
show_menu() {
clear_screen
echo "Discord Bot Selection and Configuration"
echo "------------------------------------"
echo "Available Bots:"
# List available bots from prompts directory
if [ -d "agent/prompts" ]; then
for dir in agent/prompts/*/; do
if [ -d "$dir" ]; then
basename=$(basename "$dir")
# Skip directories starting with . or __
if [[ ! "$basename" =~ ^\. ]] && [[ ! "$basename" =~ ^__ ]]; then
echo " $basename"
fi
fi
done
fi
echo ""
}
# Function to show API menu
show_api_menu() {
local bot_name="$1"
clear_screen
echo "API Selection for $bot_name"
echo "----------------------"
echo "1. Ollama (Local)"
echo "2. OpenAI"
echo "3. Anthropic"
echo "4. vLLM (Local)"
echo "5. Gemini"
echo "----------------------"
echo "6. Back to Bot Selection"
echo "7. Exit"
echo ""
}
# Function to handle Ollama selection
handle_ollama() {
local bot_name="$1"
clear_screen
echo "Selected: Ollama (via API)"
echo ""
read -p "Enter model name (or press Enter for default): " model
# Ask for DMN settings
echo ""
echo "DMN (Background Thought Generation) Settings:"
read -p "Enter DMN API type (ollama/openai/anthropic/vllm/gemini or Enter for main API): " dmn_api
read -p "Enter DMN model name (or press Enter for main model): " dmn_model
# Build command with DMN options
cmd="python agent/discord_bot.py --api ollama --bot-name \"$bot_name\""
if [ -n "$model" ]; then
cmd="$cmd --model \"$model\""
fi
if [ -n "$dmn_api" ]; then
cmd="$cmd --dmn-api \"$dmn_api\""
fi
if [ -n "$dmn_model" ]; then
cmd="$cmd --dmn-model \"$dmn_model\""
fi
eval $cmd
}
# Function to handle other API selections
handle_api() {
local api_name="$1"
local bot_name="$2"
clear_screen
echo "Selected: $api_name"
# Show available models for OpenAI
if [ "$api_name" == "openai" ]; then
echo ""
echo "Available OpenAI Models:"
echo "----------------------"
python -c "from dotenv import load_dotenv; import openai, os; load_dotenv(); client = openai.OpenAI(api_key=os.getenv('OPENAI_API_KEY')); models = client.models.list(); [print(m.id) for m in sorted(models.data, key=lambda x: x.id) if any(x in m.id for x in ['gpt', 'o1', 'o3'])]" 2>/dev/null || echo "(OPENAI_API_KEY not set - cannot fetch models)"
echo "----------------------"
echo ""
fi
read -p "Enter model name (or press Enter for default): " model
# Ask for DMN settings
echo ""
echo "DMN (Background Thought Generation) Settings:"
read -p "Enter DMN API type (ollama/openai/anthropic/vllm/gemini or Enter for main API): " dmn_api
read -p "Enter DMN model name (or press Enter for main model): " dmn_model
# Build command with DMN options
cmd="python agent/discord_bot.py --api \"$api_name\" --bot-name \"$bot_name\""
if [ -n "$model" ]; then
cmd="$cmd --model \"$model\""
fi
if [ -n "$dmn_api" ]; then
cmd="$cmd --dmn-api \"$dmn_api\""
fi
if [ -n "$dmn_model" ]; then
cmd="$cmd --dmn-model \"$dmn_model\""
fi
eval $cmd
}
# Main function
main() {
while true; do
show_menu
read -p "Enter bot name (or press Enter for default): " bot_name
# Set default bot name if empty
if [ -z "$bot_name" ]; then
bot_name="default"
fi
# API selection loop
while true; do
show_api_menu "$bot_name"
read -p "Enter your choice (1-7): " choice
case $choice in
1)
handle_ollama "$bot_name"
exit 0
;;
2)
handle_api "openai" "$bot_name"
exit 0
;;
3)
handle_api "anthropic" "$bot_name"
exit 0
;;
4)
handle_api "vllm" "$bot_name"
exit 0
;;
5)
handle_api "gemini" "$bot_name"
exit 0
;;
6)
# Go back to bot selection
break
;;
7)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid choice. Please try again."
sleep 2
;;
esac
done
done
}
# Run main function
main