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

Function normalizeToolResultOutput

coderd/x/chatd/chatdebug/model.go:927–971  ·  view source on GitHub ↗
(output fantasy.ToolResultOutputContent)

Source from the content-addressed store, hash-verified

925}
926
927func normalizeToolResultOutput(output fantasy.ToolResultOutputContent) string {
928 switch v := output.(type) {
929 case fantasy.ToolResultOutputContentText:
930 return boundText(v.Text)
931 case *fantasy.ToolResultOutputContentText:
932 if v == nil {
933 return ""
934 }
935 return boundText(v.Text)
936 case fantasy.ToolResultOutputContentError:
937 if v.Error == nil {
938 return ""
939 }
940 return boundText(v.Error.Error())
941 case *fantasy.ToolResultOutputContentError:
942 if v == nil || v.Error == nil {
943 return ""
944 }
945 return boundText(v.Error.Error())
946 case fantasy.ToolResultOutputContentMedia:
947 if v.Text != "" {
948 return boundText(v.Text)
949 }
950 if v.MediaType == "" {
951 return "[media output]"
952 }
953 return fmt.Sprintf("[media output: %s]", v.MediaType)
954 case *fantasy.ToolResultOutputContentMedia:
955 if v == nil {
956 return ""
957 }
958 if v.Text != "" {
959 return boundText(v.Text)
960 }
961 if v.MediaType == "" {
962 return "[media output]"
963 }
964 return fmt.Sprintf("[media output: %s]", v.MediaType)
965 default:
966 if output == nil {
967 return ""
968 }
969 return boundText(string(safeMarshalJSON("tool result output", output)))
970 }
971}
972
973// isNilInterfaceValue reports whether v is nil or holds a nil pointer,
974// map, slice, channel, or func.

Callers 3

normalizeMessagePartsFunction · 0.85
normalizeContentPartsFunction · 0.85

Calls 3

boundTextFunction · 0.85
safeMarshalJSONFunction · 0.85
ErrorMethod · 0.45

Tested by 1