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

Function parseLegacyContent

coderd/x/chatd/chatprompt/chatprompt.go:357–370  ·  view source on GitHub ↗

parseLegacyContent handles content version 0, where the format varies by role and era. Uses structural heuristics to distinguish fantasy envelope format from SDK parts.

(role codersdk.ChatMessageRole, raw pqtype.NullRawMessage)

Source from the content-addressed store, hash-verified

355// varies by role and era. Uses structural heuristics to distinguish
356// fantasy envelope format from SDK parts.
357func parseLegacyContent(role codersdk.ChatMessageRole, raw pqtype.NullRawMessage) ([]codersdk.ChatMessagePart, error) {
358 switch role {
359 case codersdk.ChatMessageRoleSystem:
360 return parseSystemRole(raw)
361 case codersdk.ChatMessageRoleAssistant:
362 return parseAssistantRole(raw)
363 case codersdk.ChatMessageRoleTool:
364 return parseToolRole(raw)
365 case codersdk.ChatMessageRoleUser:
366 return parseUserRole(raw)
367 default:
368 return nil, xerrors.Errorf("unsupported chat message role %q", role)
369 }
370}
371
372// parseContentV1 handles content version 1. Content is a JSON
373// array of ChatMessagePart structs.

Callers 1

ParseContentFunction · 0.85

Calls 5

parseSystemRoleFunction · 0.85
parseAssistantRoleFunction · 0.85
parseToolRoleFunction · 0.85
parseUserRoleFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected