44406b72db
Moteva-style AI design workbench replica. Home prompt creates a project; the project page provides an infinite canvas with node drag, zoom/pan, a design chat panel, history replay, image asset upload, and project save/regenerate. - Backend: go-zero, DDD layering, sqlc/pgx, optional PostgreSQL; memory or Redis cache; asynq job queue; MinIO/S3/R2/OSS object storage; sky-valley/pi agent runtime adapter. - Frontend: Next.js App Router + Vite artifact build, TypeScript, i18n, shadcn/ui components, auth (OTP/Turnstile/Google/WeChat). - Deploy: Docker Compose and k3s manifests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
39 lines
885 B
Go
39 lines
885 B
Go
package logic
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"img_infinite_canvas/internal/domain/design"
|
|
)
|
|
|
|
func validateRequiredPrompt(prompt string, allowEmpty bool) error {
|
|
if allowEmpty {
|
|
return nil
|
|
}
|
|
if hasRequiredPromptText(prompt) {
|
|
return nil
|
|
}
|
|
return fmt.Errorf("%w: prompt is required", design.ErrInvalidInput)
|
|
}
|
|
|
|
func hasRequiredPromptText(prompt string) bool {
|
|
for _, line := range strings.Split(prompt, "\n") {
|
|
line = strings.TrimSpace(strings.ReplaceAll(line, "\u00a0", " "))
|
|
if line == "" || isPromptReferenceDirective(line) {
|
|
continue
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func isPromptReferenceDirective(line string) bool {
|
|
lower := strings.ToLower(line)
|
|
hasURL := strings.Contains(lower, "http://") || strings.Contains(lower, "https://")
|
|
if !hasURL {
|
|
return false
|
|
}
|
|
return strings.HasPrefix(line, "参考图") || strings.HasPrefix(lower, "reference image")
|
|
}
|