feat: 添加 VitePress 文档站和 Gitea CI 部署
Some checks failed
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
Some checks failed
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
- 新增 docs/ 目录,使用 VitePress 构建文档站 - 添加 .gitea/workflows/deploy.yaml,部署到 Cloudflare Pages - 新增 setup.sh 一站式安装脚本(兼容 macOS bash 3.x) - 修复 Gemini CLI 脚本认证头(改用 Authorization: Bearer) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -132,15 +132,15 @@ function Test-ApiConnection {
|
||||
try {
|
||||
$headers = @{
|
||||
"Content-Type" = "application/json"
|
||||
"x-goog-api-key" = $ApiKey
|
||||
"Authorization" = "Bearer $ApiKey"
|
||||
}
|
||||
|
||||
$testEndpoint = "$baseUrl/v1/models"
|
||||
$response = Invoke-RestMethod -Uri $testEndpoint -Method Get -Headers $headers -ErrorAction Stop
|
||||
|
||||
# Check if response contains models
|
||||
if ($response.models) {
|
||||
$modelCount = $response.models.Count
|
||||
# Check if response contains models (supports both data and models arrays)
|
||||
if ($response.data -or $response.models) {
|
||||
$modelCount = if ($response.data) { $response.data.Count } else { $response.models.Count }
|
||||
Write-Success "API connection successful! Found $modelCount models at $baseUrl"
|
||||
return $baseUrl
|
||||
} else {
|
||||
|
||||
10
GeminiCLI/setup-gemini.sh
Normal file → Executable file
10
GeminiCLI/setup-gemini.sh
Normal file → Executable file
@@ -84,19 +84,19 @@ test_api_connection() {
|
||||
|
||||
local test_endpoint="$base_url/v1/models"
|
||||
|
||||
# Test with x-goog-api-key header (Gemini API style)
|
||||
# Test with Authorization Bearer header (XCodeCLI API style)
|
||||
local response
|
||||
response=$(curl -s -w "%{http_code}" -o /tmp/gemini_test_response \
|
||||
-X GET "$test_endpoint" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-goog-api-key: $api_key" \
|
||||
-H "Authorization: Bearer $api_key" \
|
||||
2>/dev/null || echo "000")
|
||||
|
||||
if [ "$response" = "200" ]; then
|
||||
# Check if response contains models
|
||||
if grep -q '"models"' /tmp/gemini_test_response 2>/dev/null; then
|
||||
# Check if response contains models (supports both {data:[]} and {models:[]} formats)
|
||||
if grep -qE '"(data|models)"' /tmp/gemini_test_response 2>/dev/null; then
|
||||
local model_count
|
||||
model_count=$(grep -oE '"name"[[:space:]]*:' /tmp/gemini_test_response | wc -l | tr -d ' ')
|
||||
model_count=$(grep -oE '"id"[[:space:]]*:' /tmp/gemini_test_response | wc -l | tr -d ' ')
|
||||
print_success "API connection successful! Found $model_count models at $base_url" >&2
|
||||
rm -f /tmp/gemini_test_response
|
||||
echo "$base_url"
|
||||
|
||||
Reference in New Issue
Block a user