11#nullable enable
22using System ;
3- using System . Collections . Generic ;
43using UnityEngine ;
54using ProjectVG . Infrastructure . Network . DTOs . Chat ;
65
@@ -12,31 +11,41 @@ public class ChatMessage
1211 public string SessionId { get ; set ; } = string . Empty ;
1312 public string ? Text { get ; set ; }
1413 public VoiceData ? VoiceData { get ; set ; }
14+ public CharacterActionData ? ActionData { get ; set ; }
15+ public CostInfo ? CostInfo { get ; set ; }
1516 public DateTime Timestamp { get ; set ; } = DateTime . UtcNow ;
16- public Dictionary < string , object > ? Metadata { get ; set ; }
1717
1818 public static ChatMessage FromChatResponse ( ChatResponse response )
1919 {
20- var chatMessage = new ChatMessage
21- {
20+ var chatMessage = new ChatMessage {
2221 SessionId = response . SessionId ,
2322 Text = response . Text ,
2423 Timestamp = response . Timestamp ,
25- Metadata = response . Metadata
24+ ActionData = new CharacterActionData ( response . Action )
2625 } ;
2726
2827 if ( ! string . IsNullOrEmpty ( response . AudioData ) )
2928 {
3029 chatMessage . VoiceData = VoiceData . FromBase64 ( response . AudioData , response . AudioFormat ) ;
3130 }
3231
32+ if ( ( response . UsedCost ?? 0 ) > 0 || ( response . RemainingCost ?? 0 ) > 0 )
33+ {
34+ chatMessage . CostInfo = new CostInfo ( response . UsedCost ?? 0f , response . RemainingCost ?? 0f ) ;
35+ }
36+
3337 return chatMessage ;
3438 }
3539
3640 public bool HasVoiceData ( ) => VoiceData != null && VoiceData . IsPlayable ( ) ;
3741
3842 public bool HasTextData ( ) => ! string . IsNullOrEmpty ( Text ) ;
43+
44+ public bool HasActionData ( ) => ActionData != null && ActionData . HasAction ( ) ;
45+
46+ public bool HasCostInfo ( ) => CostInfo != null && CostInfo . HasCostInfo ( ) ;
3947
4048 public AudioClip ? GetAudioClip ( ) => VoiceData ? . AudioClip ;
49+
4150 }
4251}
0 commit comments