Image input
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
package claude_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"image/png"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -198,6 +203,30 @@ func TestInterrupt(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageInput(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testContext(t)
|
||||
s := start(t, ctx, claude.Options{Cwd: scratchRepo(t)})
|
||||
|
||||
img := image.NewRGBA(image.Rect(0, 0, 64, 64))
|
||||
draw.Draw(img, img.Bounds(), &image.Uniform{C: color.RGBA{R: 255, A: 255}}, image.Point{}, draw.Src)
|
||||
buf := bytes.Buffer{}
|
||||
err := png.Encode(&buf, img)
|
||||
if err != nil {
|
||||
t.Fatalf("encode png: %v", err)
|
||||
}
|
||||
|
||||
err = s.Send("Without using any tools, what single colour fills the attached image? Reply with just the colour name.", claude.Image{MediaType: "image/png", Data: buf.Bytes()})
|
||||
if err != nil {
|
||||
t.Fatalf("send: %v", err)
|
||||
}
|
||||
text := waitResult(t, ctx, s, nil)
|
||||
|
||||
if !strings.Contains(strings.ToLower(text), "red") {
|
||||
t.Fatalf("model didn't see the image; assistant said %q", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResume(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testContext(t)
|
||||
|
||||
Reference in New Issue
Block a user