feat: 测试路径

This commit is contained in:
tbphp
2025-07-23 14:35:52 +08:00
parent e40f33190a
commit ec04555a50
10 changed files with 164 additions and 79 deletions

View File

@@ -9,6 +9,7 @@ import (
"gpt-load/internal/models"
"io"
"net/http"
"net/url"
"strings"
"github.com/gin-gonic/gin"
@@ -66,7 +67,14 @@ func (ch *OpenAIChannel) ValidateKey(ctx context.Context, key string) (bool, err
return false, fmt.Errorf("no upstream URL configured for channel %s", ch.Name)
}
reqURL := upstreamURL.String() + "/v1/chat/completions"
validationEndpoint := ch.ValidationEndpoint
if validationEndpoint == "" {
validationEndpoint = "/v1/chat/completions"
}
reqURL, err := url.JoinPath(upstreamURL.String(), validationEndpoint)
if err != nil {
return false, fmt.Errorf("failed to join upstream URL and validation endpoint: %w", err)
}
// Use a minimal, low-cost payload for validation
payload := gin.H{