Spaces:
Running
Running
Somrat Sorkar commited on
Commit ·
6275d3e
1
Parent(s): d41fe21
Fix: Support Gemini models properly with google/ prefix and correct agents config
Browse files
start.sh
CHANGED
|
@@ -32,6 +32,21 @@ fi
|
|
| 32 |
LLM_PROVIDER="${LLM_PROVIDER:-anthropic}"
|
| 33 |
LLM_MODEL="${LLM_MODEL:-anthropic/claude-haiku-4-5}"
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
case "$LLM_PROVIDER" in
|
| 36 |
anthropic) export ANTHROPIC_API_KEY="$LLM_API_KEY" ;;
|
| 37 |
openai) export OPENAI_API_KEY="$LLM_API_KEY" ;;
|
|
@@ -138,9 +153,20 @@ CONFIG_JSON=$(cat <<'CONFIGEOF'
|
|
| 138 |
CONFIGEOF
|
| 139 |
)
|
| 140 |
|
| 141 |
-
# Gateway token
|
| 142 |
CONFIG_JSON=$(echo "$CONFIG_JSON" | jq ".gateway.auth.token = \"$GATEWAY_TOKEN\"")
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
# Control UI origin (allow HF Space URL for web UI access)
|
| 146 |
if [ -n "$SPACE_HOST" ]; then
|
|
|
|
| 32 |
LLM_PROVIDER="${LLM_PROVIDER:-anthropic}"
|
| 33 |
LLM_MODEL="${LLM_MODEL:-anthropic/claude-haiku-4-5}"
|
| 34 |
|
| 35 |
+
# Auto-correct Gemini models to use google/ prefix if anthropic/ was mistakenly used
|
| 36 |
+
if [[ "$LLM_MODEL" == "anthropic/gemini"* ]]; then
|
| 37 |
+
LLM_MODEL=$(echo "$LLM_MODEL" | sed 's/^anthropic\//google\//')
|
| 38 |
+
echo "⚠️ Corrected model from anthropic/gemini* to google/gemini*"
|
| 39 |
+
fi
|
| 40 |
+
|
| 41 |
+
# Auto-detect provider from model name if not explicitly set
|
| 42 |
+
if [[ "$LLM_MODEL" == "google/"* ]]; then
|
| 43 |
+
LLM_PROVIDER="google"
|
| 44 |
+
elif [[ "$LLM_MODEL" == "openai/"* ]]; then
|
| 45 |
+
LLM_PROVIDER="openai"
|
| 46 |
+
elif [[ "$LLM_MODEL" == "anthropic/"* ]] || [[ "$LLM_MODEL" == "claude"* ]]; then
|
| 47 |
+
LLM_PROVIDER="anthropic"
|
| 48 |
+
fi
|
| 49 |
+
|
| 50 |
case "$LLM_PROVIDER" in
|
| 51 |
anthropic) export ANTHROPIC_API_KEY="$LLM_API_KEY" ;;
|
| 52 |
openai) export OPENAI_API_KEY="$LLM_API_KEY" ;;
|
|
|
|
| 153 |
CONFIGEOF
|
| 154 |
)
|
| 155 |
|
| 156 |
+
# Gateway token
|
| 157 |
CONFIG_JSON=$(echo "$CONFIG_JSON" | jq ".gateway.auth.token = \"$GATEWAY_TOKEN\"")
|
| 158 |
+
|
| 159 |
+
# Add agents array with model configuration
|
| 160 |
+
CONFIG_JSON=$(echo "$CONFIG_JSON" | jq ".agents = [
|
| 161 |
+
{
|
| 162 |
+
\"id\": \"main\",
|
| 163 |
+
\"kind\": \"main\",
|
| 164 |
+
\"sandbox\": \"require\",
|
| 165 |
+
\"defaults\": {
|
| 166 |
+
\"model\": \"$LLM_MODEL\"
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
]")
|
| 170 |
|
| 171 |
# Control UI origin (allow HF Space URL for web UI access)
|
| 172 |
if [ -n "$SPACE_HOST" ]; then
|