fixed free-model-collector
This commit is contained in:
+15
-1
@@ -45,6 +45,9 @@ $REQ https://zsnonsky-nim-proxy.hf.space/v1/models | jq -r '.data[] | "\(.id),-,
|
||||
# Write XORTRON as hardcode
|
||||
echo 'xortron,-,https://darkc0de-chat.hf.space/v1,'>> "$TCONFIG"
|
||||
|
||||
# Write hygate as hardcode
|
||||
echo 'hy3,-,http://127.0.0.1:9875/v1,'>> "$TCONFIG"
|
||||
|
||||
# Verify each collected model for responsiveness under the actual /chat/completions
|
||||
# (prompt it to respond with OK). Unresponsive models are dropped from the final file.
|
||||
# For non-timeout drops, the HTTP response code is reported for diagnostics.
|
||||
@@ -53,6 +56,13 @@ SKIPF="$(mktemp)"
|
||||
# OpenCode Zen endpoints require an X-Session-ID header on chat requests
|
||||
sid="$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid 2>/dev/null || python3 -c 'import uuid;print(uuid.uuid4())' 2>/dev/null)"
|
||||
[ -z "$sid" ] && sid="$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' ')"
|
||||
# Quote an arbitrary value as a single CSV field (RFC 4180). The extra
|
||||
# column carries a JSON header map such as {"User-Agent":"opencode/1.18.30"};
|
||||
# its bare double quotes would otherwise abort the Go encoding/csv reader
|
||||
# on configuration reload.
|
||||
csv_quote() {
|
||||
printf '"%s"' "$(printf '%s' "$1" | sed 's/"/""/g')"
|
||||
}
|
||||
while IFS=',' read -r model key endpoint extra; do
|
||||
[ -z "$model" ] && continue
|
||||
case "$model" in *embed*) echo "Skipped (embedding model): $model @ $endpoint" >&2; continue;; esac
|
||||
@@ -102,7 +112,11 @@ while IFS=',' read -r model key endpoint extra; do
|
||||
done
|
||||
if [ "$ok" -eq 1 ]; then
|
||||
echo "Added: $model @ $endpoint (TTFT: ${ttft}s)"
|
||||
printf '%s,%s,%s,%s\n' "$model" "$key" "$endpoint" "$extra" >> "$VCONFIG"
|
||||
if [ -n "$extra" ]; then
|
||||
printf '%s,%s,%s,%s\n' "$model" "$key" "$endpoint" "$(csv_quote "$extra")" >> "$VCONFIG"
|
||||
else
|
||||
printf '%s,%s,%s,%s\n' "$model" "$key" "$endpoint" "" >> "$VCONFIG"
|
||||
fi
|
||||
else
|
||||
echo "Unresponsive ($reason), dropped: $model @ $endpoint" >&2
|
||||
if [ "$rc" -eq 6 ] || [ "$rc" -eq 7 ]; then
|
||||
|
||||
Reference in New Issue
Block a user