返回 DeepSeek-Reasonix
history_attachments.go
根目录 / desktop / history_attachments.go
1 package main
2
3 import (
4 "reasonix/internal/attachment"
5 "reasonix/internal/transcript"
6 )
7
8 func historyDisplayAttachments(inputs []attachment.ImageInput) []transcript.Attachment {
9 if len(inputs) == 0 {
10 return nil
11 }
12 out := make([]transcript.Attachment, 0, len(inputs))
13 for _, in := range inputs {
14 switch in.Kind {
15 case attachment.KindAttachment:
16 if in.Attachment == nil {
17 continue
18 }
19 out = append(out, transcript.Attachment{
20 Kind: "image",
21 Digest: in.Attachment.Digest(),
22 Name: in.Attachment.DisplayName,
23 MIME: in.Attachment.MIME(),
24 Width: in.Attachment.Width,
25 Height: in.Attachment.Height,
26 Bytes: in.Attachment.Content.Bytes,
27 })
28 case attachment.KindURL:
29 if in.URL == "" {
30 continue
31 }
32 out = append(out, transcript.Attachment{Kind: "url", Name: in.URL})
33 case attachment.KindFiles:
34 if in.FilesID == "" {
35 continue
36 }
37 out = append(out, transcript.Attachment{Kind: "files", Name: in.FilesID})
38 }
39 }
40 if len(out) == 0 {
41 return nil
42 }
43 return out
44 }
45
45 lines GO