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)
| 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. |
| 69 | func 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 | } |
no test coverage detected