MCPcopy Create free account
hub / github.com/coder/coder / formatSyntheticPasteText

Function formatSyntheticPasteText

coderd/x/chatd/chatprompt/chatprompt.go:1315–1330  ·  view source on GitHub ↗
(name string, body []byte)

Source from the content-addressed store, hash-verified

1313}
1314
1315func formatSyntheticPasteText(name string, body []byte) string {
1316 const syntheticPasteNameLabel = "Synthetic attachment name: "
1317 const syntheticPasteNameSuffix = "\n\n"
1318
1319 var sb strings.Builder
1320 sb.Grow(len(syntheticPasteInlinePrefix) + len(name) + min(len(body), syntheticPasteInlineBudget) + len(syntheticPasteTruncationWarning) + len(syntheticPasteNameLabel) + len(syntheticPasteNameSuffix))
1321 _, _ = sb.WriteString(syntheticPasteInlinePrefix)
1322 if name != "" {
1323 _, _ = fmt.Fprintf(&sb, "%s%s%s", syntheticPasteNameLabel, name, syntheticPasteNameSuffix)
1324 }
1325 _, _ = sb.WriteString(string(body[:min(len(body), syntheticPasteInlineBudget)]))
1326 if len(body) > syntheticPasteInlineBudget {
1327 _, _ = sb.WriteString(syntheticPasteTruncationWarning)
1328 }
1329 return sb.String()
1330}
1331
1332func formatMissingAttachmentText(mediaType string) string {
1333 const missingAttachmentBody = "[missing-attachment] The user attached a file here, but the content has expired and is no longer available."

Callers 1

partsToMessagePartsFunction · 0.85

Calls 2

WriteStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected