diff --git a/HttpGPT.uplugin b/HttpGPT.uplugin index c3c75a7..2aedd2b 100644 --- a/HttpGPT.uplugin +++ b/HttpGPT.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 22, - "VersionName": "1.5.9", + "Version": 23, + "VersionName": "1.5.10", "FriendlyName": "HttpGPT - GPT Integration", "Description": "HttpGPT is an Unreal Engine plugin that facilitates integration with OpenAI's GPT based services (ChatGPT and DALL-E) through asynchronous REST requests, making it easy for developers to communicate with these services. HttpGPT also includes new Editor Tools to integrate Chat GPT and DALL-E image generation directly in the Engine.", "Category": "Game Features", diff --git a/Source/HttpGPTChatModule/Private/Tasks/HttpGPTChatRequest.cpp b/Source/HttpGPTChatModule/Private/Tasks/HttpGPTChatRequest.cpp index 87b811b..86ccbab 100644 --- a/Source/HttpGPTChatModule/Private/Tasks/HttpGPTChatRequest.cpp +++ b/Source/HttpGPTChatModule/Private/Tasks/HttpGPTChatRequest.cpp @@ -81,7 +81,7 @@ bool UHttpGPTChatRequest::CanActivateTask() const if (HttpGPT::Internal::HasEmptyParam(Messages)) { - UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Can't activate task: Invalid Messages."), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Can't activate task: Invalid Messages."), *FString(__FUNCTION__), GetUniqueID()); return false; } @@ -116,7 +116,7 @@ FString UHttpGPTChatRequest::SetRequestContent() return FString(); } - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Mounting content"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Mounting content"), *FString(__FUNCTION__), GetUniqueID()); const TSharedPtr JsonRequest = MakeShared(); JsonRequest->SetStringField("model", UHttpGPTHelper::ModelToName(GetChatOptions().Model).ToString().ToLower()); @@ -157,7 +157,7 @@ FString UHttpGPTChatRequest::SetRequestContent() if (UHttpGPTHelper::ModelSupportsChat(GetChatOptions().Model)) { - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Selected model supports Chat API. Mounting section history."), *FString(__func__), + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Selected model supports Chat API. Mounting section history."), *FString(__FUNCTION__), GetUniqueID()); TArray> MessagesJson; @@ -182,7 +182,7 @@ FString UHttpGPTChatRequest::SetRequestContent() else { UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Selected model does not supports Chat API. Using last message as prompt content."), - *FString(__func__), GetUniqueID()); + *FString(__FUNCTION__), GetUniqueID()); JsonRequest->SetStringField("prompt", Messages.Top().Content); } @@ -206,8 +206,8 @@ void UHttpGPTChatRequest::OnProgressUpdated(const FString& Content, int32 BytesS TArray Deltas = GetDeltasFromContent(Content); - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Progress Updated"), *FString(__func__), GetUniqueID()); - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Content: %s; Bytes Sent: %d; Bytes Received: %d"), *FString(__func__), GetUniqueID(), + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Progress Updated"), *FString(__FUNCTION__), GetUniqueID()); + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Content: %s; Bytes Sent: %d; Bytes Received: %d"), *FString(__FUNCTION__), GetUniqueID(), *Deltas.Top(), BytesSent, BytesReceived); DeserializeStreamedResponse(Deltas); @@ -245,7 +245,7 @@ void UHttpGPTChatRequest::OnProgressCompleted(const FString& Content, const bool if (!bWasSuccessful || HttpGPT::Internal::HasEmptyParam(Content)) { - UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Request failed"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Request failed"), *FString(__FUNCTION__), GetUniqueID()); AsyncTask(ENamedThreads::GameThread, [this] { RequestFailed.Broadcast(); @@ -254,8 +254,8 @@ void UHttpGPTChatRequest::OnProgressCompleted(const FString& Content, const bool return; } - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Process Completed"), *FString(__func__), GetUniqueID()); - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Content: %s"), *FString(__func__), GetUniqueID(), *Content); + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Process Completed"), *FString(__FUNCTION__), GetUniqueID()); + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Content: %s"), *FString(__FUNCTION__), GetUniqueID(), *Content); if (!GetChatOptions().bStream) { @@ -283,7 +283,7 @@ void UHttpGPTChatRequest::OnProgressCompleted(const FString& Content, const bool } else { - UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Request failed"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Request failed"), *FString(__FUNCTION__), GetUniqueID()); AsyncTask(ENamedThreads::GameThread, [this] { FScopeLock Lock(&Mutex); @@ -342,16 +342,16 @@ void UHttpGPTChatRequest::DeserializeSingleResponse(const FString& Content) Response.bSuccess = true; - Response.ID = *JsonResponse->GetStringField("id"); - Response.Object = *JsonResponse->GetStringField("object"); - Response.Created = JsonResponse->GetNumberField("created"); + Response.ID = *JsonResponse->GetStringField(TEXT("id")); + Response.Object = *JsonResponse->GetStringField(TEXT("object")); + Response.Created = JsonResponse->GetNumberField(TEXT("created")); - const TArray> ChoicesArr = JsonResponse->GetArrayField("choices"); + const TArray> ChoicesArr = JsonResponse->GetArrayField(TEXT("choices")); for (auto Iterator = ChoicesArr.CreateConstIterator(); Iterator; ++Iterator) { const TSharedPtr ChoiceObj = (*Iterator)->AsObject(); - const int32 ChoiceIndex = ChoiceObj->GetIntegerField("index"); + const int32 ChoiceIndex = ChoiceObj->GetIntegerField(TEXT("index")); FHttpGPTChatChoice* Choice = Response.Choices.FindByPredicate([this, ChoiceIndex](const FHttpGPTChatChoice& Element) { @@ -365,54 +365,54 @@ void UHttpGPTChatRequest::DeserializeSingleResponse(const FString& Content) Choice = &Response.Choices.Add_GetRef(NewChoice); } - if (const TSharedPtr* MessageObj; ChoiceObj->TryGetObjectField("message", MessageObj)) + if (const TSharedPtr* MessageObj; ChoiceObj->TryGetObjectField(TEXT("message"), MessageObj)) { - if (FString RoleStr; (*MessageObj)->TryGetStringField("role", RoleStr)) + if (FString RoleStr; (*MessageObj)->TryGetStringField(TEXT("role"), RoleStr)) { Choice->Message.Role = RoleStr == "user" ? EHttpGPTChatRole::User : EHttpGPTChatRole::Assistant; } - if (FString ContentStr; (*MessageObj)->TryGetStringField("content", ContentStr)) + if (FString ContentStr; (*MessageObj)->TryGetStringField(TEXT("content"), ContentStr)) { Choice->Message.Content = ContentStr; } - if (const TSharedPtr* FunctionObj; (*MessageObj)->TryGetObjectField("function_call", FunctionObj)) + if (const TSharedPtr* FunctionObj; (*MessageObj)->TryGetObjectField(TEXT("function_call"), FunctionObj)) { - if (FString FunctionNameStr; (*FunctionObj)->TryGetStringField("name", FunctionNameStr)) + if (FString FunctionNameStr; (*FunctionObj)->TryGetStringField(TEXT("name"), FunctionNameStr)) { Choice->Message.FunctionCall.Name = *FunctionNameStr; } - if (FString FunctionArgumentsStr; (*FunctionObj)->TryGetStringField("arguments", FunctionArgumentsStr)) + if (FString FunctionArgumentsStr; (*FunctionObj)->TryGetStringField(TEXT("arguments"), FunctionArgumentsStr)) { Choice->Message.FunctionCall.Arguments = FunctionArgumentsStr; } } } - else if (const TSharedPtr* DeltaObj; ChoiceObj->TryGetObjectField("delta", DeltaObj)) + else if (const TSharedPtr* DeltaObj; ChoiceObj->TryGetObjectField(TEXT("delta"), DeltaObj)) { - if (FString RoleStr; (*DeltaObj)->TryGetStringField("role", RoleStr)) + if (FString RoleStr; (*DeltaObj)->TryGetStringField(TEXT("role"), RoleStr)) { Choice->Message.Role = UHttpGPTHelper::NameToRole(*RoleStr); } - else if (FString ContentStr; (*DeltaObj)->TryGetStringField("content", ContentStr)) + else if (FString ContentStr; (*DeltaObj)->TryGetStringField(TEXT("content"), ContentStr)) { Choice->Message.Content += ContentStr; } - if (const TSharedPtr* FunctionObj; (*DeltaObj)->TryGetObjectField("function_call", FunctionObj)) + if (const TSharedPtr* FunctionObj; (*DeltaObj)->TryGetObjectField(TEXT("function_call"), FunctionObj)) { - if (FString FunctionNameStr; (*FunctionObj)->TryGetStringField("name", FunctionNameStr)) + if (FString FunctionNameStr; (*FunctionObj)->TryGetStringField(TEXT("name"), FunctionNameStr)) { Choice->Message.FunctionCall.Name = *FunctionNameStr; } - if (FString FunctionArgumentsStr; (*FunctionObj)->TryGetStringField("arguments", FunctionArgumentsStr)) + if (FString FunctionArgumentsStr; (*FunctionObj)->TryGetStringField(TEXT("arguments"), FunctionArgumentsStr)) { Choice->Message.FunctionCall.Arguments += FunctionArgumentsStr; } } } - else if (FString MessageText; ChoiceObj->TryGetStringField("text", MessageText)) + else if (FString MessageText; ChoiceObj->TryGetStringField(TEXT("text"), MessageText)) { Choice->Message.Role = EHttpGPTChatRole::Assistant; Choice->Message.Content += MessageText; @@ -423,16 +423,16 @@ void UHttpGPTChatRequest::DeserializeSingleResponse(const FString& Content) Choice->Message.Content.RemoveAt(0); } - if (FString FinishReasonStr; ChoiceObj->TryGetStringField("finish_reason", FinishReasonStr)) + if (FString FinishReasonStr; ChoiceObj->TryGetStringField(TEXT("finish_reason"), FinishReasonStr)) { Choice->FinishReason = *FinishReasonStr; } } - if (const TSharedPtr* UsageObj; JsonResponse->TryGetObjectField("usage", UsageObj)) + if (const TSharedPtr* UsageObj; JsonResponse->TryGetObjectField(TEXT("usage"), UsageObj)) { - Response.Usage = FHttpGPTChatUsage((*UsageObj)->GetNumberField("prompt_tokens"), (*UsageObj)->GetNumberField("completion_tokens"), - (*UsageObj)->GetNumberField("total_tokens")); + Response.Usage = FHttpGPTChatUsage((*UsageObj)->GetNumberField(TEXT("prompt_tokens")), (*UsageObj)->GetNumberField(TEXT("completion_tokens")), + (*UsageObj)->GetNumberField(TEXT("total_tokens"))); } } diff --git a/Source/HttpGPTCommonModule/Private/Tasks/HttpGPTBaseTask.cpp b/Source/HttpGPTCommonModule/Private/Tasks/HttpGPTBaseTask.cpp index 8a5edf7..87a1fe7 100644 --- a/Source/HttpGPTCommonModule/Private/Tasks/HttpGPTBaseTask.cpp +++ b/Source/HttpGPTCommonModule/Private/Tasks/HttpGPTBaseTask.cpp @@ -29,7 +29,7 @@ void UHttpGPTBaseTask::Activate() { Super::Activate(); - UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Activating task"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Activating task"), *FString(__FUNCTION__), GetUniqueID()); bIsTaskActive = true; if (!CommonOptions.Endpoint.EndsWith(TEXT("/"))) @@ -39,7 +39,7 @@ void UHttpGPTBaseTask::Activate() if (!CanActivateTask()) { - UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Failed to activate task."), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Failed to activate task."), *FString(__FUNCTION__), GetUniqueID()); RequestFailed.Broadcast(); SetReadyToDestroy(); return; @@ -71,7 +71,7 @@ void UHttpGPTBaseTask::StopHttpGPTTask() return; } - UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Stopping task"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Stopping task"), *FString(__FUNCTION__), GetUniqueID()); bIsTaskActive = false; @@ -93,7 +93,7 @@ void UHttpGPTBaseTask::SetReadyToDestroy() return; } - UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Setting task as Ready to Destroy"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Setting task as Ready to Destroy"), *FString(__FUNCTION__), GetUniqueID()); #if WITH_EDITOR if (bIsEditorTask) @@ -132,7 +132,7 @@ void UHttpGPTBaseTask::PrePIEEnded(bool bIsSimulating) return; } - UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Trying to finish task due to PIE end"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Trying to finish task due to PIE end"), *FString(__FUNCTION__), GetUniqueID()); bEndingPIE = true; StopHttpGPTTask(); @@ -143,7 +143,7 @@ bool UHttpGPTBaseTask::CanActivateTask() const { if (HttpGPT::Internal::HasEmptyParam(GetCommonOptions().APIKey)) { - UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Can't activate task: Invalid API Key."), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Can't activate task: Invalid API Key."), *FString(__FUNCTION__), GetUniqueID()); return false; } @@ -164,7 +164,7 @@ void UHttpGPTBaseTask::InitializeRequest() { FScopeLock Lock(&Mutex); - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Initializing request object"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Initializing request object"), *FString(__FUNCTION__), GetUniqueID()); HttpRequest = FHttpModule::Get().CreateRequest(); HttpRequest->SetURL(GetEndpointURL()); @@ -182,11 +182,15 @@ void UHttpGPTBaseTask::BindRequestCallbacks() return; } - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Binding callbacks"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Binding callbacks"), *FString(__FUNCTION__), GetUniqueID()); if (CanBindProgress()) { +#if ENGINE_MAJOR_VERSION > 5 || (ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 4) + HttpRequest->OnRequestProgress64().BindLambda([this](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived) +#else HttpRequest->OnRequestProgress().BindLambda([this](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived) +#endif { const FScopeTryLock Lock(&Mutex); @@ -226,7 +230,7 @@ void UHttpGPTBaseTask::SendRequest() if (!HttpRequest.IsValid()) { - UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Failed to send request: Request object is invalid"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Failed to send request: Request object is invalid"), *FString(__FUNCTION__), GetUniqueID()); AsyncTask(ENamedThreads::GameThread, [this] { @@ -237,12 +241,12 @@ void UHttpGPTBaseTask::SendRequest() return; } - UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Sending request"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Sending request"), *FString(__FUNCTION__), GetUniqueID()); if (HttpRequest->ProcessRequest()) { - UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Request sent"), *FString(__func__), GetUniqueID()); - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Request content body:\n%s"), *FString(__func__), GetUniqueID(), *ContentString); + UE_LOG(LogHttpGPT, Display, TEXT("%s (%d): Request sent"), *FString(__FUNCTION__), GetUniqueID()); + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Request content body:\n%s"), *FString(__FUNCTION__), GetUniqueID(), *ContentString); AsyncTask(ENamedThreads::GameThread, [this] { @@ -251,7 +255,7 @@ void UHttpGPTBaseTask::SendRequest() } else { - UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Failed to initialize the request process"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Failed to initialize the request process"), *FString(__FUNCTION__), GetUniqueID()); AsyncTask(ENamedThreads::GameThread, [this] { RequestFailed.Broadcast(); @@ -262,18 +266,18 @@ void UHttpGPTBaseTask::SendRequest() const bool UHttpGPTBaseTask::CheckError(const TSharedPtr& JsonObject, FHttpGPTCommonError& OutputError) const { - if (JsonObject->HasField("error")) + if (JsonObject->HasField(TEXT("error"))) { - const TSharedPtr ErrorObj = JsonObject->GetObjectField("error"); - if (FString ErrorMessage; ErrorObj->TryGetStringField("message", ErrorMessage)) + const TSharedPtr ErrorObj = JsonObject->GetObjectField(TEXT("error")); + if (FString ErrorMessage; ErrorObj->TryGetStringField(TEXT("message"), ErrorMessage)) { OutputError.Message = *ErrorMessage; } - if (FString ErrorCode; ErrorObj->TryGetStringField("code", ErrorCode)) + if (FString ErrorCode; ErrorObj->TryGetStringField(TEXT("code"), ErrorCode)) { OutputError.Code = *ErrorCode; } - if (FString ErrorType; ErrorObj->TryGetStringField("type", ErrorType)) + if (FString ErrorType; ErrorObj->TryGetStringField(TEXT("type"), ErrorType)) { OutputError.Type = *ErrorType; } diff --git a/Source/HttpGPTEditorModule/Private/Chat/SHttpGPTChatView.cpp b/Source/HttpGPTEditorModule/Private/Chat/SHttpGPTChatView.cpp index 27fba33..3f60b95 100644 --- a/Source/HttpGPTEditorModule/Private/Chat/SHttpGPTChatView.cpp +++ b/Source/HttpGPTEditorModule/Private/Chat/SHttpGPTChatView.cpp @@ -21,7 +21,7 @@ void SHttpGPTChatView::Construct(const FArguments& InArgs) { SetSessionID(InArgs._SessionID); - ModelsComboBox = SNew(STextComboBox).OptionsSource(&AvailableModels).ToolTipText(FText::FromString(TEXT("GPT Model"))); + SAssignNew(ModelsComboBox, STextComboBox).OptionsSource(&AvailableModels).ToolTipText(FText::FromString(TEXT("GPT Model"))); for (const FName& ModelName : UHttpGPTHelper::GetAvailableGPTModels()) { @@ -230,7 +230,7 @@ FString SHttpGPTChatView::GetDefaultSystemContext() const } FString SupportedModels; - for (const FTextDisplayStringPtr& Model : AvailableModels) + for (const TSharedPtr& Model : AvailableModels) { SupportedModels.Append(*Model.Get() + ", "); } @@ -298,16 +298,16 @@ void SHttpGPTChatView::LoadChatHistory() const TSharedRef> Reader = TJsonReaderFactory<>::Create(FileContent); if (FJsonSerializer::Deserialize(Reader, JsonParsed)) { - const TArray> SessionData = JsonParsed->GetArrayField("Data"); + const TArray> SessionData = JsonParsed->GetArrayField(TEXT("Data")); for (const TSharedPtr& Item : SessionData) { if (const TSharedPtr MessageItObj = Item->AsObject()) { - if (FString RoleString; MessageItObj->TryGetStringField("role", RoleString)) + if (FString RoleString; MessageItObj->TryGetStringField(TEXT("role"), RoleString)) { const EHttpGPTChatRole Role = UHttpGPTHelper::NameToRole(*RoleString); - if (FString Message; MessageItObj->TryGetStringField("content", Message)) + if (FString Message; MessageItObj->TryGetStringField(TEXT("content"), Message)) { if (Role == EHttpGPTChatRole::System && Message == GetDefaultSystemContext()) { diff --git a/Source/HttpGPTEditorModule/Private/Chat/SHttpGPTChatView.h b/Source/HttpGPTEditorModule/Private/Chat/SHttpGPTChatView.h index 4f487c7..4b9dd6f 100644 --- a/Source/HttpGPTEditorModule/Private/Chat/SHttpGPTChatView.h +++ b/Source/HttpGPTEditorModule/Private/Chat/SHttpGPTChatView.h @@ -53,7 +53,7 @@ class SHttpGPTChatView final : public SCompoundWidget TSharedPtr InputTextBox; TSharedPtr ModelsComboBox; - TArray AvailableModels; + TArray> AvailableModels; TWeakObjectPtr RequestReference; }; diff --git a/Source/HttpGPTEditorModule/Private/ImageGen/SHttpGPTImageGenView.h b/Source/HttpGPTEditorModule/Private/ImageGen/SHttpGPTImageGenView.h index f8d17a0..f7482db 100644 --- a/Source/HttpGPTEditorModule/Private/ImageGen/SHttpGPTImageGenView.h +++ b/Source/HttpGPTEditorModule/Private/ImageGen/SHttpGPTImageGenView.h @@ -36,8 +36,8 @@ class SHttpGPTImageGenView final : public SCompoundWidget TSharedPtr InputTextBox; TSharedPtr ImageNumComboBox; - TArray ImageNum; + TArray> ImageNum; TSharedPtr ImageSizeComboBox; - TArray ImageSize; + TArray> ImageSize; }; diff --git a/Source/HttpGPTImageModule/Private/Tasks/HttpGPTImageRequest.cpp b/Source/HttpGPTImageModule/Private/Tasks/HttpGPTImageRequest.cpp index 34eca29..784b208 100644 --- a/Source/HttpGPTImageModule/Private/Tasks/HttpGPTImageRequest.cpp +++ b/Source/HttpGPTImageModule/Private/Tasks/HttpGPTImageRequest.cpp @@ -78,7 +78,7 @@ bool UHttpGPTImageRequest::CanActivateTask() const if (HttpGPT::Internal::HasEmptyParam(Prompt)) { - UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Can't activate task: Invalid Prompt."), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Can't activate task: Invalid Prompt."), *FString(__FUNCTION__), GetUniqueID()); return false; } @@ -109,7 +109,7 @@ FString UHttpGPTImageRequest::SetRequestContent() return FString(); } - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Mounting content"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Mounting content"), *FString(__FUNCTION__), GetUniqueID()); const TSharedPtr JsonRequest = MakeShared(); JsonRequest->SetStringField("prompt", Prompt); @@ -137,7 +137,7 @@ void UHttpGPTImageRequest::OnProgressCompleted(const FString& Content, const boo if (!bWasSuccessful || HttpGPT::Internal::HasEmptyParam(Content)) { - UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Request failed"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Request failed"), *FString(__FUNCTION__), GetUniqueID()); AsyncTask(ENamedThreads::GameThread, [this] { RequestFailed.Broadcast(); @@ -146,8 +146,8 @@ void UHttpGPTImageRequest::OnProgressCompleted(const FString& Content, const boo return; } - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Process Completed"), *FString(__func__), GetUniqueID()); - UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Content: %s"), *FString(__func__), GetUniqueID(), *Content); + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Process Completed"), *FString(__FUNCTION__), GetUniqueID()); + UE_LOG(LogHttpGPT_Internal, Display, TEXT("%s (%d): Content: %s"), *FString(__FUNCTION__), GetUniqueID(), *Content); DeserializeResponse(Content); @@ -161,7 +161,7 @@ void UHttpGPTImageRequest::OnProgressCompleted(const FString& Content, const boo } else { - UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Request failed"), *FString(__func__), GetUniqueID()); + UE_LOG(LogHttpGPT, Error, TEXT("%s (%d): Request failed"), *FString(__FUNCTION__), GetUniqueID()); AsyncTask(ENamedThreads::GameThread, [this] { FScopeLock Lock(&Mutex); @@ -190,9 +190,9 @@ void UHttpGPTImageRequest::DeserializeResponse(const FString& Content) } Response.bSuccess = true; - Response.Created = JsonResponse->GetNumberField("created"); + Response.Created = JsonResponse->GetNumberField(TEXT("created")); - const TArray> DataArray = JsonResponse->GetArrayField("data"); + const TArray> DataArray = JsonResponse->GetArrayField(TEXT("data")); for (auto Iterator = DataArray.CreateConstIterator(); Iterator; ++Iterator) { Response.Data.Add(FHttpGPTImageData(