#!/bin/bash
C=$(docker ps --format "{{.Names}}" | grep "friend-deploy" | head -1)
FT=$(docker exec postgres_db psql -U knowledge -d yunwoai -t -A -c "SELECT friend_token FROM user_friend_agents WHERE instance_id='friend-abc1d454';")
echo "=== 渠道下全部模型 ==="
docker exec $C sh -c "wget -O /tmp/models.json --header=\"Authorization: Bearer $FT\" http://127.0.0.1:8000/api/llm/channels/1/models 2>/dev/null" 
docker exec $C sh -c "cat /tmp/models.json" | python3 -c "
import sys,json
try:
    for m in json.load(sys.stdin):
        r=m.get(\"runtime\") or {}
        print(m.get(\"id\"), m.get(\"model_key\"), \"state:\", r.get(\"state\"))
except Exception as e: print(\"err:\", e, sys.stdin.read()[:100] if not sys.stdin.closed else '')
"
