MCPcopy
hub / github.com/wavetermdev/waveterm / ConvertAIChatToUIChat

Function ConvertAIChatToUIChat

pkg/aiusechat/usechat-utils.go:69–85  ·  view source on GitHub ↗

ConvertAIChatToUIChat converts an AIChat to a UIChat by routing to the appropriate provider-specific converter based on APIType, then combining consecutive same-role messages.

(aiChat *uctypes.AIChat)

Source from the content-addressed store, hash-verified

67// ConvertAIChatToUIChat converts an AIChat to a UIChat by routing to the appropriate
68// provider-specific converter based on APIType, then combining consecutive same-role messages.
69func ConvertAIChatToUIChat(aiChat *uctypes.AIChat) (*uctypes.UIChat, error) {
70 if aiChat == nil {
71 return nil, nil
72 }
73
74 backend, err := GetBackendByAPIType(aiChat.APIType)
75 if err != nil {
76 return nil, err
77 }
78
79 uiChat, err := backend.ConvertAIChatToUIChat(*aiChat)
80 if err != nil {
81 return nil, err
82 }
83
84 return CombineConsecutiveSameRoleMessages(uiChat), nil
85}

Callers 1

GetWaveAIChatCommandMethod · 0.92

Calls 3

GetBackendByAPITypeFunction · 0.85
ConvertAIChatToUIChatMethod · 0.65

Tested by

no test coverage detected