MCPcopy Index your code
hub / github.com/coder/coder / ContentPartSize

Function ContentPartSize

coderd/x/chatd/chatloop/metrics.go:192–207  ·  view source on GitHub ↗

ContentPartSize returns the byte length of a MessagePart's primary text or data field.

(part fantasy.MessagePart)

Source from the content-addressed store, hash-verified

190// ContentPartSize returns the byte length of a MessagePart's
191// primary text or data field.
192func ContentPartSize(part fantasy.MessagePart) int {
193 switch p := part.(type) {
194 case fantasy.TextPart:
195 return len(p.Text)
196 case fantasy.ReasoningPart:
197 return len(p.Text)
198 case fantasy.FilePart:
199 return len(p.Data)
200 case fantasy.ToolCallPart:
201 return len(p.Input)
202 case fantasy.ToolResultPart:
203 return toolResultOutputSize(p.Output)
204 default:
205 return 0
206 }
207}
208
209// ToolResultSize returns the byte length of a
210// ToolResultContent's primary text or data field.

Callers 1

EstimatePromptSizeFunction · 0.85

Calls 1

toolResultOutputSizeFunction · 0.85

Tested by

no test coverage detected