UnrealVoxta 0.1.1
 
Loading...
Searching...
No Matches
ChatMessage.h
Go to the documentation of this file.
1// Copyright(c) 2024 grrimgrriefer & DZnnah, see LICENSE for details.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "ChatMessage.generated.h"
7
14USTRUCT(BlueprintType, Category = "Voxta")
16{
17 GENERATED_BODY()
18
19#pragma region public API
20public:
27 const FGuid& GetMessageId() const { return m_messageId; }
28
35 const FGuid& GetCharId() const { return m_charId; }
36
43 FStringView GetTextContent() const { return m_text; }
44
51 const TArray<FString>& GetAudioUrls() const { return m_audioUrls; }
52
59 bool GetIsComplete() const { return m_isComplete; }
60
67 bool TryAppendMoreContent(const FString& textContent, const FString& audioUrl)
68 {
69 if (m_isComplete)
70 {
71 return false;
72 }
73
74 m_text.Append(textContent);
75 if (!audioUrl.IsEmpty()) // text only response is valid, but we don't add empty audio urls ofc
76 {
77 m_audioUrls.Emplace(audioUrl);
78 }
79 return true;
80 }
81
86 {
87 m_isComplete = true;
88 }
89
97 explicit FChatMessage(FGuid messageId, FGuid charId) :
98 m_messageId(messageId),
99 m_charId(charId)
100 {}
101
103 FChatMessage() = default;
104#pragma endregion
105
106private:
108 UPROPERTY(BlueprintReadOnly, Category = "Voxta", meta = (AllowPrivateAccess = "true", DisplayName = "Message Text (so far)"))
109 FString m_text;
110
112 UPROPERTY(BlueprintReadOnly, Category = "Voxta", meta = (AllowPrivateAccess = "true", DisplayName = "Message ID"))
113 FGuid m_messageId;
114
116 UPROPERTY(BlueprintReadOnly, Category = "Voxta", meta = (AllowPrivateAccess = "true", DisplayName = "Character ID"))
117 FGuid m_charId;
118
120 bool m_isComplete = false;
121
123 TArray<FString> m_audioUrls;
124};
const TArray< FString > & GetAudioUrls() const
Get the list of audio URLs for this message's synthesized speech.
Definition ChatMessage.h:51
bool GetIsComplete() const
Check if this message is complete with no further chunks expected.
Definition ChatMessage.h:59
const FGuid & GetCharId() const
Get the ID of the character who sent this message.
Definition ChatMessage.h:35
bool TryAppendMoreContent(const FString &textContent, const FString &audioUrl)
Add more data to this message, as VoxtaServer notifies us of the complete data in chunks.
Definition ChatMessage.h:67
FChatMessage()=default
Default constructor.
FChatMessage(FGuid messageId, FGuid charId)
Create an instance of the chat message for the User data.
Definition ChatMessage.h:97
FStringView GetTextContent() const
Get the current text content of the message.
Definition ChatMessage.h:43
void MarkComplete()
Mark this message as complete, indicating no further chunks are expected.
Definition ChatMessage.h:85
const FGuid & GetMessageId() const
Get the unique identifier assigned to this message.
Definition ChatMessage.h:27