Nerdur commited on
Commit
0b9cbb6
·
verified ·
1 Parent(s): 8a76f67

Upload setup_endpoints.sh

Browse files
Files changed (1) hide show
  1. setup_endpoints.sh +46 -72
setup_endpoints.sh CHANGED
@@ -2,7 +2,6 @@
2
 
3
  BASE_URL="http://localhost:8080"
4
 
5
- # Čekaj da WebUI stvarno odgovara
6
  echo "Čekam da WebUI bude spreman..."
7
  for i in {1..30}; do
8
  STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$BASE_URL/health")
@@ -14,26 +13,19 @@ for i in {1..30}; do
14
  sleep 5
15
  done
16
 
17
- # Login kao admin i dobij token
18
  echo "Logujem se kao admin..."
19
  LOGIN_RESPONSE=$(curl -s -X POST "$BASE_URL/api/v1/auths/signin" \
20
  -H "Content-Type: application/json" \
21
- -d '{
22
- "email": "nermindurma1981@gmail.com",
23
- "password": "nerko1508"
24
- }')
25
 
26
  TOKEN=$(echo $LOGIN_RESPONSE | python3 -c "import sys, json; print(json.load(sys.stdin).get('token', ''))")
27
 
28
  if [ -z "$TOKEN" ]; then
29
- echo "❌ Login neuspješan, pokušavam registraciju admina..."
30
  REGISTER_RESPONSE=$(curl -s -X POST "$BASE_URL/api/v1/auths/signup" \
31
  -H "Content-Type: application/json" \
32
- -d '{
33
- "name": "nermin",
34
- "email": "nermindurma1981@gmail.com",
35
- "password": "nerko1508"
36
- }')
37
  TOKEN=$(echo $REGISTER_RESPONSE | python3 -c "import sys, json; print(json.load(sys.stdin).get('token', ''))")
38
  fi
39
 
@@ -42,70 +34,52 @@ if [ -z "$TOKEN" ]; then
42
  exit 0
43
  fi
44
 
45
- echo "✅ Ulogovan, konfiguriram endpointe..."
46
 
47
- # Dohvati trenutnu OpenAI config
48
- CURRENT_CONFIG=$(curl -s "$BASE_URL/openai/config" \
49
- -H "Authorization: Bearer $TOKEN")
50
-
51
- echo "Trenutna config: $CURRENT_CONFIG"
52
-
53
- # Funkcija za dodavanje endpointa kroz /openai/config
54
- add_endpoint() {
55
- local NAME=$1
56
- local URL=$2
57
- local KEY=$3
58
-
59
- curl -s -X POST "$BASE_URL/api/v1/configs/connections" \
60
- -H "Content-Type: application/json" \
61
- -H "Authorization: Bearer $TOKEN" \
62
- -d "{
63
- \"openai\": {
64
- \"connections\": [
65
- {
66
- \"name\": \"$NAME\",
67
- \"url\": \"$URL\",
68
- \"key\": \"$KEY\",
69
- \"enable\": true
70
- }
71
- ]
72
- }
73
- }" > /dev/null 2>&1
74
-
75
- echo "✅ Dodan: $NAME"
76
- }
77
-
78
- # Kreiraj sve konekcije odjednom kao jedan payload
79
- echo "Dodajem sve endpointe odjednom..."
80
-
81
- curl -s -X POST "$BASE_URL/api/v1/configs/connections" \
82
  -H "Content-Type: application/json" \
83
  -H "Authorization: Bearer $TOKEN" \
84
  -d "{
85
- \"openai\": {
86
- \"connections\": [
87
- {\"id\": \"openai\", \"name\": \"OpenAI\", \"url\": \"https://api.openai.com/v1\", \"key\": \"$OPENAI_API_KEY\", \"enable\": true},
88
- {\"id\": \"anthropic\", \"name\": \"Anthropic\", \"url\": \"https://api.anthropic.com/v1\", \"key\": \"$ANTHROPIC_API_KEY\", \"enable\": true},
89
- {\"id\": \"gemini\", \"name\": \"Google Gemini\", \"url\": \"https://generativelanguage.googleapis.com/v1beta/openai\", \"key\": \"$GOOGLE_API_KEY\", \"enable\": true},
90
- {\"id\": \"github\", \"name\": \"GitHub Models\", \"url\": \"https://models.inference.ai.azure.com\", \"key\": \"$GITHUB_TOKEN\", \"enable\": true},
91
- {\"id\": \"groq\", \"name\": \"Groq\", \"url\": \"https://api.groq.com/openai/v1\", \"key\": \"$GROQ_API_KEY\", \"enable\": true},
92
- {\"id\": \"mistral\", \"name\": \"Mistral\", \"url\": \"https://api.mistral.ai/v1\", \"key\": \"$MISTRAL_API_KEY\", \"enable\": true},
93
- {\"id\": \"deepseek\", \"name\": \"Deepseek\", \"url\": \"https://api.deepseek.com/v1\", \"key\": \"$DEEPSEEK_API_KEY\", \"enable\": true},
94
- {\"id\": \"together\", \"name\": \"Together AI\", \"url\": \"https://api.together.xyz/v1\", \"key\": \"$TOGETHER_API_KEY\", \"enable\": true},
95
- {\"id\": \"nvidia\", \"name\": \"Nvidia\", \"url\": \"https://integrate.api.nvidia.com/v1\", \"key\": \"$NVIDIA_API_KEY\", \"enable\": true},
96
- {\"id\": \"sambanova\", \"name\": \"Sambanova\", \"url\": \"https://api.sambanova.ai/v1\", \"key\": \"$SAMBANOVA_API_KEY\", \"enable\": true},
97
- {\"id\": \"openrouter\", \"name\": \"OpenRouter\", \"url\": \"https://openrouter.ai/api/v1\", \"key\": \"$OPENROUTER_API_KEY\", \"enable\": true},
98
- {\"id\": \"cloudflare\", \"name\": \"Cloudflare AI\", \"url\": \"https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1\", \"key\": \"$CLOUDFLARE_API_TOKEN\", \"enable\": true},
99
- {\"id\": \"cerebras\", \"name\": \"Cerebras\", \"url\": \"https://api.cerebras.ai/v1\", \"key\": \"$CEREBRAS_API_KEY\", \"enable\": true},
100
- {\"id\": \"fireworks\", \"name\": \"Fireworks\", \"url\": \"https://api.fireworks.ai/inference/v1\", \"key\": \"$FIREWORKS_API_KEY\", \"enable\": true},
101
- {\"id\": \"xai\", \"name\": \"xAI Grok\", \"url\": \"https://api.x.ai/v1\", \"key\": \"$XAI_API_KEY\", \"enable\": true},
102
- {\"id\": \"huggingface\", \"name\": \"Hugging Face\", \"url\": \"https://api-inference.huggingface.co/v1\", \"key\": \"$HUGGINGFACE_API_KEY\", \"enable\": true},
103
- {\"id\": \"cohere\", \"name\": \"Cohere\", \"url\": \"https://api.cohere.ai/compatibility/v1\", \"key\": \"$COHERE_API_KEY\", \"enable\": true}
104
- ]
105
- },
106
- \"ollama\": {
107
- \"connections\": []
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }"
110
 
111
  echo ""
 
2
 
3
  BASE_URL="http://localhost:8080"
4
 
 
5
  echo "Čekam da WebUI bude spreman..."
6
  for i in {1..30}; do
7
  STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$BASE_URL/health")
 
13
  sleep 5
14
  done
15
 
16
+ # Login
17
  echo "Logujem se kao admin..."
18
  LOGIN_RESPONSE=$(curl -s -X POST "$BASE_URL/api/v1/auths/signin" \
19
  -H "Content-Type: application/json" \
20
+ -d '{"email": "nermindurma1981@gmail.com", "password": "nerko1508"}')
 
 
 
21
 
22
  TOKEN=$(echo $LOGIN_RESPONSE | python3 -c "import sys, json; print(json.load(sys.stdin).get('token', ''))")
23
 
24
  if [ -z "$TOKEN" ]; then
25
+ echo "❌ Login neuspješan, pokušavam registraciju..."
26
  REGISTER_RESPONSE=$(curl -s -X POST "$BASE_URL/api/v1/auths/signup" \
27
  -H "Content-Type: application/json" \
28
+ -d '{"name": "nermin", "email": "nermindurma1981@gmail.com", "password": "nerko1508"}')
 
 
 
 
29
  TOKEN=$(echo $REGISTER_RESPONSE | python3 -c "import sys, json; print(json.load(sys.stdin).get('token', ''))")
30
  fi
31
 
 
34
  exit 0
35
  fi
36
 
37
+ echo "✅ Ulogovan, konfiguriram endpointe kroz /openai/config/update..."
38
 
39
+ curl -s -X POST "$BASE_URL/openai/config/update" \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  -H "Content-Type: application/json" \
41
  -H "Authorization: Bearer $TOKEN" \
42
  -d "{
43
+ \"ENABLE_OPENAI_API\": true,
44
+ \"OPENAI_API_BASE_URLS\": [
45
+ \"https://api.openai.com/v1\",
46
+ \"https://api.anthropic.com/v1\",
47
+ \"https://generativelanguage.googleapis.com/v1beta/openai\",
48
+ \"https://models.inference.ai.azure.com\",
49
+ \"https://api.groq.com/openai/v1\",
50
+ \"https://api.mistral.ai/v1\",
51
+ \"https://api.deepseek.com/v1\",
52
+ \"https://api.together.xyz/v1\",
53
+ \"https://integrate.api.nvidia.com/v1\",
54
+ \"https://api.sambanova.ai/v1\",
55
+ \"https://openrouter.ai/api/v1\",
56
+ \"https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1\",
57
+ \"https://api.cerebras.ai/v1\",
58
+ \"https://api.fireworks.ai/inference/v1\",
59
+ \"https://api.x.ai/v1\",
60
+ \"https://api-inference.huggingface.co/v1\",
61
+ \"https://api.cohere.ai/compatibility/v1\"
62
+ ],
63
+ \"OPENAI_API_KEYS\": [
64
+ \"$OPENAI_API_KEY\",
65
+ \"$ANTHROPIC_API_KEY\",
66
+ \"$GOOGLE_API_KEY\",
67
+ \"$GITHUB_TOKEN\",
68
+ \"$GROQ_API_KEY\",
69
+ \"$MISTRAL_API_KEY\",
70
+ \"$DEEPSEEK_API_KEY\",
71
+ \"$TOGETHER_API_KEY\",
72
+ \"$NVIDIA_API_KEY\",
73
+ \"$SAMBANOVA_API_KEY\",
74
+ \"$OPENROUTER_API_KEY\",
75
+ \"$CLOUDFLARE_API_TOKEN\",
76
+ \"$CEREBRAS_API_KEY\",
77
+ \"$FIREWORKS_API_KEY\",
78
+ \"$XAI_API_KEY\",
79
+ \"$HUGGINGFACE_API_KEY\",
80
+ \"$COHERE_API_KEY\"
81
+ ],
82
+ \"OPENAI_API_CONFIGS\": {}
83
  }"
84
 
85
  echo ""