AI wizard/test/doctor: native-auth handling, Responses API test, safe temp, stale profile
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp
This commit is contained in:
+11
-6
@@ -18,6 +18,8 @@ harness=$(cn_ai_profile_field "$profile" harness)
|
||||
provider=$(cn_ai_profile_field "$profile" provider)
|
||||
model=$(cn_ai_profile_field "$profile" model)
|
||||
proto=$(cn_ai_harness_field "$harness" protocol)
|
||||
# Codex speaks the Responses API (wire_api=responses), not chat/completions
|
||||
[[ $harness == "codex" ]] && proto="openai-responses"
|
||||
failures=0
|
||||
|
||||
if [[ $proto == "native" ]]; then
|
||||
@@ -26,7 +28,7 @@ if [[ $proto == "native" ]]; then
|
||||
fi
|
||||
|
||||
# Endpoint override for mock-server tests
|
||||
base="${OMARCHYCN_AI_TEST_BASE_URL:-$(cn_ai_endpoint "$provider" "$proto")}"
|
||||
base="${OMARCHYCN_AI_TEST_BASE_URL:-$(cn_ai_endpoint "$provider" "${proto%-responses}")}"
|
||||
echo "INFO ai-test: $profile ($harness x $provider x $model) -> $base"
|
||||
|
||||
if ! key=$(omarchy-cn-ai-secret get "$provider" 2>/dev/null); then
|
||||
@@ -34,16 +36,19 @@ if ! key=$(omarchy-cn-ai-secret get "$provider" 2>/dev/null); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
body=$(mktemp)
|
||||
trap 'rm -f "$body"' EXIT
|
||||
|
||||
case "$proto" in
|
||||
anthropic)
|
||||
code=$(curl -sS -o /tmp/omarchycn-ai-test-body -w '%{http_code}' -m 30 --connect-timeout 8 \
|
||||
code=$(curl -sS -o "$body" -w '%{http_code}' -m 30 --connect-timeout 8 \
|
||||
-X POST "${base%/}/v1/messages" \
|
||||
-H "x-api-key: $key" -H "authorization: Bearer $key" \
|
||||
-H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
|
||||
-d "{\"model\":\"$model\",\"max_tokens\":8,\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}]}" || true)
|
||||
;;
|
||||
openai)
|
||||
code=$(curl -sS -o /tmp/omarchycn-ai-test-body -w '%{http_code}' -m 30 --connect-timeout 8 \
|
||||
code=$(curl -sS -o "$body" -w '%{http_code}' -m 30 --connect-timeout 8 \
|
||||
-X POST "${base%/}/chat/completions" \
|
||||
-H "Authorization: Bearer $key" -H "content-type: application/json" \
|
||||
-d "{\"model\":\"$model\",\"max_tokens\":8,\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}]}" || true)
|
||||
@@ -65,7 +70,7 @@ case "$code" in
|
||||
;;
|
||||
404 | 400 | 422)
|
||||
echo "FAIL ai-test: 端点可达但请求被拒 (HTTP $code),可能是模型名问题"
|
||||
head -c 200 /tmp/omarchycn-ai-test-body 2>/dev/null && echo
|
||||
head -c 200 "$body" 2>/dev/null && echo
|
||||
failures=$((failures + 1))
|
||||
;;
|
||||
000)
|
||||
@@ -74,10 +79,10 @@ case "$code" in
|
||||
;;
|
||||
*)
|
||||
echo "FAIL ai-test: HTTP $code"
|
||||
head -c 200 /tmp/omarchycn-ai-test-body 2>/dev/null && echo
|
||||
head -c 200 "$body" 2>/dev/null && echo
|
||||
failures=$((failures + 1))
|
||||
;;
|
||||
esac
|
||||
|
||||
rm -f /tmp/omarchycn-ai-test-body
|
||||
rm -f $body
|
||||
exit $((failures > 0 ? 1 : 0))
|
||||
|
||||
Reference in New Issue
Block a user