ba4db85241
Strip inline image tokens and reference directive URLs before deciding whether a prompt carries real user text, so a reference-only prompt is still treated as empty while text around references counts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
25 lines
1.1 KiB
Go
25 lines
1.1 KiB
Go
package logic
|
||
|
||
import "testing"
|
||
|
||
func TestHasRequiredPromptTextAllowsInlineReferenceContext(t *testing.T) {
|
||
prompt := "参考图 1(0.jpg):http://localhost:19000/canvas-assets/a.webp 为服装品牌 stillday 创建情绪板 logo 设计 参考图 2(image.png):http://localhost:19000/canvas-assets/b.png ,包含材质、色彩、摄影姿态。"
|
||
if !hasRequiredPromptText(prompt) {
|
||
t.Fatalf("expected inline text around reference directives to count as prompt text")
|
||
}
|
||
}
|
||
|
||
func TestHasRequiredPromptTextRejectsReferenceOnlyPrompt(t *testing.T) {
|
||
prompt := "参考图 1(0.jpg):http://localhost:19000/canvas-assets/a.webp\nReference image 2 (image.png): https://example.com/b.png"
|
||
if hasRequiredPromptText(prompt) {
|
||
t.Fatalf("expected reference-only prompt to be treated as empty")
|
||
}
|
||
}
|
||
|
||
func TestHasRequiredPromptTextHandlesChinesePunctuationAfterReference(t *testing.T) {
|
||
prompt := "参考图 1(image.png):https://example.com/reference.png,参考它的字体做 logo。"
|
||
if !hasRequiredPromptText(prompt) {
|
||
t.Fatalf("expected text after Chinese punctuation to count as prompt text")
|
||
}
|
||
}
|