去掉1500字数限制
This commit is contained in:
@@ -70,7 +70,7 @@ func (h *UserGenerationHandler) Generate(c *gin.Context) {
|
||||
switch {
|
||||
case errors.Is(err, service.ErrUnknownModel):
|
||||
c.JSON(http.StatusNotFound, gin.H{"detail": err.Error()})
|
||||
case errors.Is(err, service.ErrUnsupportedParams), errors.Is(err, service.ErrPromptTooLong):
|
||||
case errors.Is(err, service.ErrUnsupportedParams):
|
||||
c.JSON(http.StatusBadRequest, gin.H{"detail": err.Error()})
|
||||
case errors.Is(err, service.ErrInsufficientFunds):
|
||||
c.JSON(http.StatusPaymentRequired, gin.H{"detail": "积分不足"})
|
||||
@@ -132,7 +132,7 @@ func (h *UserGenerationHandler) Test(c *gin.Context) {
|
||||
switch {
|
||||
case errors.Is(err, service.ErrUnknownModel):
|
||||
c.JSON(http.StatusNotFound, gin.H{"detail": err.Error()})
|
||||
case errors.Is(err, service.ErrUnsupportedParams), errors.Is(err, service.ErrPromptTooLong):
|
||||
case errors.Is(err, service.ErrUnsupportedParams):
|
||||
c.JSON(http.StatusBadRequest, gin.H{"detail": err.Error()})
|
||||
case errors.Is(err, service.ErrProviderQuota):
|
||||
c.JSON(http.StatusTooManyRequests, gin.H{"detail": err.Error()})
|
||||
|
||||
@@ -316,7 +316,7 @@ func (h *V1Handler) writeV1Error(c *gin.Context, err error, payload map[string]a
|
||||
switch {
|
||||
case errors.Is(err, service.ErrUnknownModel):
|
||||
c.JSON(http.StatusNotFound, gin.H{"detail": err.Error()})
|
||||
case errors.Is(err, service.ErrUnsupportedParams), errors.Is(err, service.ErrPromptTooLong):
|
||||
case errors.Is(err, service.ErrUnsupportedParams):
|
||||
c.JSON(http.StatusBadRequest, gin.H{"detail": err.Error()})
|
||||
case errors.Is(err, service.ErrInsufficientFunds):
|
||||
c.JSON(http.StatusPaymentRequired, gin.H{"detail": err.Error()})
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"strconv"
|
||||
|
||||
@@ -38,7 +37,6 @@ var (
|
||||
ErrInvalidAPIKey = errors.New("invalid api key")
|
||||
ErrUnknownModel = errors.New("unknown model")
|
||||
ErrUnsupportedParams = errors.New("unsupported or unpriced parameters for this model")
|
||||
ErrPromptTooLong = errors.New("prompt too long (max 1500 characters)")
|
||||
ErrInsufficientFunds = errors.New("insufficient credits")
|
||||
ErrGenerationPending = errors.New("generation executor not implemented yet")
|
||||
ErrProviderAuth = errors.New("provider token invalid or expired")
|
||||
@@ -59,10 +57,6 @@ var (
|
||||
ErrVideoNotReady = errors.New("video is not ready yet")
|
||||
)
|
||||
|
||||
// maxPromptRunes caps prompt length (counted as characters, so Chinese = 1),
|
||||
// matching the 画图台 counter. Enforced for both 画图台 and API-key calls.
|
||||
const maxPromptRunes = 1500
|
||||
|
||||
// maxReferenceImageBytes bounds a single decoded reference image. 8 MB
|
||||
// comfortably covers real photos/screenshots; anything larger is almost
|
||||
// certainly abuse or a mistake. Mirrors Python core/refs.py.
|
||||
@@ -945,9 +939,6 @@ func (s *V1Service) prepareImage(ctx context.Context, principal *APIPrincipal, i
|
||||
if modelID == "" || prompt == "" {
|
||||
return nil, "", "", 0, errors.New("model and prompt required")
|
||||
}
|
||||
if utf8.RuneCountInString(prompt) > maxPromptRunes {
|
||||
return nil, "", "", 0, ErrPromptTooLong
|
||||
}
|
||||
modelItem, err := s.models.Get(ctx, modelID)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
@@ -1011,9 +1002,6 @@ func (s *V1Service) prepareVideo(ctx context.Context, principal *APIPrincipal, i
|
||||
if modelID == "" || prompt == "" {
|
||||
return nil, "", "", "", 0, errors.New("model and prompt required")
|
||||
}
|
||||
if utf8.RuneCountInString(prompt) > maxPromptRunes {
|
||||
return nil, "", "", "", 0, ErrPromptTooLong
|
||||
}
|
||||
if duration == "" {
|
||||
return nil, "", "", "", 0, errors.New("duration required")
|
||||
}
|
||||
@@ -1278,10 +1266,10 @@ const maxTempDeadAccounts = 3
|
||||
// fresh token; if it still auth-fails (or there's nothing to refresh, e.g.
|
||||
// chatgpt's JWT IS the credential), mark the account and fail over.
|
||||
// - 上游临时 temporary → behavior depends on tempFailover:
|
||||
// • tempFailover=false (default): retry the SAME account up to
|
||||
// - tempFailover=false (default): retry the SAME account up to
|
||||
// maxSameAccountAttempts times (not counted); if still failing, STOP
|
||||
// (no fan-out — an upstream-wide blip fails identically everywhere).
|
||||
// • tempFailover=true (adobe): fail over to the next account WITHOUT
|
||||
// - tempFailover=true (adobe): fail over to the next account WITHOUT
|
||||
// penalizing this one (rate-limit/overload isn't the account's fault),
|
||||
// capped at maxTempDeadAccounts accounts so a pool-wide blip can't fan
|
||||
// a single request out across everything.
|
||||
|
||||
@@ -526,9 +526,9 @@ onUnmounted(() => {
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-1.5">
|
||||
<label class="block text-xs font-medium text-slate-500">提示词</label>
|
||||
<span class="text-[11px] tabular-nums" :class="prompt.length >= 1500 ? 'text-rose-500' : 'text-slate-400'">{{ prompt.length }}/1500</span>
|
||||
<span class="text-[11px] tabular-nums text-slate-400">{{ prompt.length }}</span>
|
||||
</div>
|
||||
<textarea v-model="prompt" rows="4" maxlength="1500" class="field resize-none disabled:opacity-60 disabled:cursor-not-allowed"
|
||||
<textarea v-model="prompt" rows="4" class="field resize-none disabled:opacity-60 disabled:cursor-not-allowed"
|
||||
placeholder="描述想要的画面…如:黄昏时分,金色麦田里奔跑的金毛猎犬,电影感"></textarea>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user