MCPcopy Create free account
hub / github.com/53AI/53AIHub / buildOutputFileItems

Function buildOutputFileItems

api/controller/relay/relay_agent.go:4265–4290  ·  view source on GitHub ↗

buildOutputFileItems builds the output file items for response

(files []*model.UploadFile)

Source from the content-addressed store, hash-verified

4263
4264// buildOutputFileItems builds the output file items for response
4265func buildOutputFileItems(files []*model.UploadFile) []map[string]interface{} {
4266 if len(files) == 0 {
4267 return nil
4268 }
4269 fileItems := make([]map[string]interface{}, 0, len(files))
4270 for _, f := range files {
4271 // 将ID编码为HashID
4272 fileIDHash, _ := hashids.Encode(f.ID)
4273 messageIDHash, _ := hashids.Encode(f.MessageID)
4274 if fileIDHash == "" {
4275 fileIDHash = strconv.FormatInt(f.ID, 10)
4276 }
4277 if messageIDHash == "" {
4278 messageIDHash = strconv.FormatInt(f.MessageID, 10)
4279 }
4280 fileItems = append(fileItems, map[string]interface{}{
4281 "id": fileIDHash,
4282 "file_name": f.FileName,
4283 "url": f.GetAISignedDownloadURL(sandboxSignedDownloadTTL),
4284 "mime_type": f.MimeType,
4285 "size": f.Size,
4286 "message_id": messageIDHash,
4287 })
4288 }
4289 return fileItems
4290}
4291
4292func resolveMediaKind(mimeType string) string {
4293 lower := strings.ToLower(strings.TrimSpace(mimeType))

Callers 2

sendOutputFilesStepFunction · 0.85

Calls 2

EncodeMethod · 0.80

Tested by

no test coverage detected