Skip to content

Commit f48afda

Browse files
authored
Generate typed Go union interfaces (#1252)
* Generate typed Go union interfaces * Update Go image input docs for attachment variants * Preserve unknown permission decision kind * Simplify Go union codegen cleanup * Fix Go scenario typed union examples * Fix Go matcher codegen lint * Generate Go interfaces for shape-distinct unions * Refactor Go union codegen planning * Fix raw session event JSON fallback * Generate Go unions from required fields * regenerate
1 parent 7e7dac2 commit f48afda

42 files changed

Lines changed: 7598 additions & 2274 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/features/image-input.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ func main() {
120120
session.Send(ctx, copilot.MessageOptions{
121121
Prompt: "Describe what you see in this image",
122122
Attachments: []copilot.Attachment{
123-
{
124-
Type: copilot.AttachmentTypeFile,
125-
Path: &path,
123+
&copilot.UserMessageAttachmentFile{
124+
DisplayName: "screenshot.png",
125+
Path: path,
126126
},
127127
},
128128
})
@@ -146,9 +146,9 @@ path := "/absolute/path/to/screenshot.png"
146146
session.Send(ctx, copilot.MessageOptions{
147147
Prompt: "Describe what you see in this image",
148148
Attachments: []copilot.Attachment{
149-
{
150-
Type: copilot.AttachmentTypeFile,
151-
Path: &path,
149+
&copilot.UserMessageAttachmentFile{
150+
DisplayName: "screenshot.png",
151+
Path: path,
152152
},
153153
},
154154
})
@@ -343,10 +343,9 @@ func main() {
343343
session.Send(ctx, copilot.MessageOptions{
344344
Prompt: "Describe what you see in this image",
345345
Attachments: []copilot.Attachment{
346-
{
347-
Type: copilot.AttachmentTypeBlob,
348-
Data: &base64ImageData,
349-
MIMEType: &mimeType,
346+
&copilot.UserMessageAttachmentBlob{
347+
Data: base64ImageData,
348+
MIMEType: mimeType,
350349
DisplayName: &displayName,
351350
},
352351
},
@@ -361,10 +360,9 @@ displayName := "screenshot.png"
361360
session.Send(ctx, copilot.MessageOptions{
362361
Prompt: "Describe what you see in this image",
363362
Attachments: []copilot.Attachment{
364-
{
365-
Type: copilot.AttachmentTypeBlob,
366-
Data: &base64ImageData, // base64-encoded string
367-
MIMEType: &mimeType,
363+
&copilot.UserMessageAttachmentBlob{
364+
Data: base64ImageData, // base64-encoded string
365+
MIMEType: mimeType,
368366
DisplayName: &displayName,
369367
},
370368
},

go/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ The SDK supports image attachments via the `Attachments` field in `MessageOption
246246
_, err = session.Send(context.Background(), copilot.MessageOptions{
247247
Prompt: "What's in this image?",
248248
Attachments: []copilot.Attachment{
249-
{
250-
Type: "file",
251-
Path: "/path/to/image.jpg",
249+
&copilot.UserMessageAttachmentFile{
250+
DisplayName: "image.jpg",
251+
Path: "/path/to/image.jpg",
252252
},
253253
},
254254
})
@@ -258,10 +258,9 @@ mimeType := "image/png"
258258
_, err = session.Send(context.Background(), copilot.MessageOptions{
259259
Prompt: "What's in this image?",
260260
Attachments: []copilot.Attachment{
261-
{
262-
Type: copilot.AttachmentTypeBlob,
263-
Data: &base64ImageData,
264-
MIMEType: &mimeType,
261+
&copilot.UserMessageAttachmentBlob{
262+
Data: base64ImageData,
263+
MIMEType: mimeType,
265264
},
266265
},
267266
})

0 commit comments

Comments
 (0)