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

Function parseSystemRole

coderd/x/chatd/chatprompt/chatprompt.go:385–394  ·  view source on GitHub ↗

parseSystemRole decodes a system message (JSON string) into a single text part.

(raw pqtype.NullRawMessage)

Source from the content-addressed store, hash-verified

383// parseSystemRole decodes a system message (JSON string) into a
384// single text part.
385func parseSystemRole(raw pqtype.NullRawMessage) ([]codersdk.ChatMessagePart, error) {
386 var text string
387 if err := json.Unmarshal(raw.RawMessage, &text); err != nil {
388 return nil, xerrors.Errorf("parse system content: %w", err)
389 }
390 if strings.TrimSpace(text) == "" {
391 return nil, nil
392 }
393 return []codersdk.ChatMessagePart{codersdk.ChatMessageText(text)}, nil
394}
395
396// parseAssistantRole uses the structural heuristic to distinguish
397// legacy fantasy envelope from new SDK parts. We don't use

Callers 1

parseLegacyContentFunction · 0.85

Calls 3

ChatMessageTextFunction · 0.92
UnmarshalMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected