Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #82 from lucoiso/development
Browse files Browse the repository at this point in the history
HttpGPT v1.5.6
  • Loading branch information
lucoiso authored Aug 19, 2023
2 parents 5e38ba6 + f3ed85c commit dbe5b06
Show file tree
Hide file tree
Showing 15 changed files with 476 additions and 75 deletions.
12 changes: 6 additions & 6 deletions HttpGPT.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 18,
"VersionName": "1.5.5",
"Version": 19,
"VersionName": "1.5.6",
"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",
Expand All @@ -19,7 +19,7 @@
"Name": "HttpGPTChatModule",
"Type": "Runtime",
"LoadingPhase": "Default",
"WhitelistPlatforms": [
"PlatformAllowList": [
"Win64",
"Mac",
"Linux",
Expand All @@ -32,7 +32,7 @@
"Name": "HttpGPTImageModule",
"Type": "Runtime",
"LoadingPhase": "Default",
"WhitelistPlatforms": [
"PlatformAllowList": [
"Win64",
"Mac",
"Linux",
Expand All @@ -45,7 +45,7 @@
"Name": "HttpGPTCommonModule",
"Type": "Runtime",
"LoadingPhase": "Default",
"WhitelistPlatforms": [
"PlatformAllowList": [
"Win64",
"Mac",
"Linux",
Expand All @@ -57,7 +57,7 @@
{
"Name": "HttpGPTEditorModule",
"Type": "Editor",
"WhitelistPlatforms": [
"PlatformAllowList": [
"Win64",
"Mac",
"Linux"
Expand Down
10 changes: 5 additions & 5 deletions Source/HttpGPTChatModule/Private/Tasks/HttpGPTChatRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ UHttpGPTChatRequest* UHttpGPTChatRequest::EditorTask(const TArray<FHttpGPTChatMe
}
#endif

UHttpGPTChatRequest* UHttpGPTChatRequest::SendMessage_DefaultOptions(UObject* WorldContextObject, const FString& Message)
UHttpGPTChatRequest* UHttpGPTChatRequest::SendMessage_DefaultOptions(UObject* const WorldContextObject, const FString& Message)
{
return SendMessage_CustomOptions(WorldContextObject, Message, FHttpGPTCommonOptions(), FHttpGPTChatOptions());
}

UHttpGPTChatRequest* UHttpGPTChatRequest::SendMessages_DefaultOptions(UObject* WorldContextObject, const TArray<FHttpGPTChatMessage>& Messages)
UHttpGPTChatRequest* UHttpGPTChatRequest::SendMessages_DefaultOptions(UObject* const WorldContextObject, const TArray<FHttpGPTChatMessage>& Messages)
{
return SendMessages_CustomOptions(WorldContextObject, Messages, FHttpGPTCommonOptions(), FHttpGPTChatOptions());
}

UHttpGPTChatRequest* UHttpGPTChatRequest::SendMessage_CustomOptions(UObject* WorldContextObject, const FString& Message, const FHttpGPTCommonOptions CommonOptions, const FHttpGPTChatOptions ChatOptions)
UHttpGPTChatRequest* UHttpGPTChatRequest::SendMessage_CustomOptions(UObject* const WorldContextObject, const FString& Message, const FHttpGPTCommonOptions CommonOptions, const FHttpGPTChatOptions ChatOptions)
{
return SendMessages_CustomOptions(WorldContextObject, { FHttpGPTChatMessage(EHttpGPTChatRole::User, Message) }, CommonOptions, ChatOptions);
}

UHttpGPTChatRequest* UHttpGPTChatRequest::SendMessages_CustomOptions(UObject* WorldContextObject, const TArray<FHttpGPTChatMessage>& Messages, const FHttpGPTCommonOptions CommonOptions, const FHttpGPTChatOptions ChatOptions)
UHttpGPTChatRequest* UHttpGPTChatRequest::SendMessages_CustomOptions(UObject* const WorldContextObject, const TArray<FHttpGPTChatMessage>& Messages, const FHttpGPTCommonOptions CommonOptions, const FHttpGPTChatOptions ChatOptions)
{
UHttpGPTChatRequest* const NewAsyncTask = NewObject<UHttpGPTChatRequest>();
NewAsyncTask->Messages = Messages;
Expand Down Expand Up @@ -388,7 +388,7 @@ void UHttpGPTChatRequest::DeserializeSingleResponse(const FString& Content)
}
}

UHttpGPTChatRequest* UHttpGPTChatHelper::CastToHttpGPTChatRequest(UObject* Object)
UHttpGPTChatRequest* UHttpGPTChatHelper::CastToHttpGPTChatRequest(UObject* const Object)
{
return Cast<UHttpGPTChatRequest>(Object);
}
10 changes: 5 additions & 5 deletions Source/HttpGPTChatModule/Public/Tasks/HttpGPTChatRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ class HTTPGPTCHATMODULE_API UHttpGPTChatRequest : public UHttpGPTBaseTask
#endif

UFUNCTION(BlueprintCallable, Category = "HttpGPT | Chat | Default", meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", DisplayName = "Send Message with Default Options"))
static UHttpGPTChatRequest* SendMessage_DefaultOptions(UObject* WorldContextObject, const FString& Message);
static UHttpGPTChatRequest* SendMessage_DefaultOptions(UObject* const WorldContextObject, const FString& Message);

UFUNCTION(BlueprintCallable, Category = "HttpGPT | Chat | Default", meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", DisplayName = "Send Messages with Default Options"))
static UHttpGPTChatRequest* SendMessages_DefaultOptions(UObject* WorldContextObject, const TArray<FHttpGPTChatMessage>& Messages);
static UHttpGPTChatRequest* SendMessages_DefaultOptions(UObject* const WorldContextObject, const TArray<FHttpGPTChatMessage>& Messages);

UFUNCTION(BlueprintCallable, Category = "HttpGPT | Chat | Custom", meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", DisplayName = "Send Message with Custom Options"))
static UHttpGPTChatRequest* SendMessage_CustomOptions(UObject* WorldContextObject, const FString& Message, const FHttpGPTCommonOptions CommonOptions, const FHttpGPTChatOptions ChatOptions);
static UHttpGPTChatRequest* SendMessage_CustomOptions(UObject* const WorldContextObject, const FString& Message, const FHttpGPTCommonOptions CommonOptions, const FHttpGPTChatOptions ChatOptions);

UFUNCTION(BlueprintCallable, Category = "HttpGPT | Chat | Custom", meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", DisplayName = "Send Messages with Custom Options"))
static UHttpGPTChatRequest* SendMessages_CustomOptions(UObject* WorldContextObject, const TArray<FHttpGPTChatMessage>& Messages, const FHttpGPTCommonOptions CommonOptions, const FHttpGPTChatOptions ChatOptions);
static UHttpGPTChatRequest* SendMessages_CustomOptions(UObject* const WorldContextObject, const TArray<FHttpGPTChatMessage>& Messages, const FHttpGPTCommonOptions CommonOptions, const FHttpGPTChatOptions ChatOptions);

UFUNCTION(BlueprintPure, Category = "HttpGPT | Chat")
const FHttpGPTChatOptions GetChatOptions() const;
Expand Down Expand Up @@ -81,5 +81,5 @@ class HTTPGPTCHATMODULE_API UHttpGPTChatHelper final : public UBlueprintFunction

public:
UFUNCTION(BlueprintPure, Category = "HttpGPT | Chat", Meta = (DisplayName = "Cast to HttpGPT Chat Request"))
static UHttpGPTChatRequest* CastToHttpGPTChatRequest(UObject* Object);
static UHttpGPTChatRequest* CastToHttpGPTChatRequest(UObject* const Object);
};
12 changes: 6 additions & 6 deletions Source/HttpGPTCommonModule/Private/Utils/HttpGPTHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include UE_INLINE_GENERATED_CPP_BY_NAME(HttpGPTHelper)
#endif

const FName UHttpGPTHelper::ModelToName(const EHttpGPTChatModel& Model)
const FName UHttpGPTHelper::ModelToName(const EHttpGPTChatModel Model)
{
switch (Model)
{
Expand Down Expand Up @@ -74,7 +74,7 @@ const EHttpGPTChatModel UHttpGPTHelper::NameToModel(const FName Model)
return EHttpGPTChatModel::gpt35turbo;
}

const FName UHttpGPTHelper::RoleToName(const EHttpGPTChatRole& Role)
const FName UHttpGPTHelper::RoleToName(const EHttpGPTChatRole Role)
{
switch (Role)
{
Expand Down Expand Up @@ -124,7 +124,7 @@ const TArray<FName> UHttpGPTHelper::GetAvailableGPTModels()
return Output;
}

const FName UHttpGPTHelper::GetEndpointForModel(const EHttpGPTChatModel& Model)
const FName UHttpGPTHelper::GetEndpointForModel(const EHttpGPTChatModel Model)
{
switch (Model)
{
Expand All @@ -145,7 +145,7 @@ const FName UHttpGPTHelper::GetEndpointForModel(const EHttpGPTChatModel& Model)
return NAME_None;
}

const bool UHttpGPTHelper::ModelSupportsChat(const EHttpGPTChatModel& Model)
const bool UHttpGPTHelper::ModelSupportsChat(const EHttpGPTChatModel Model)
{
switch (Model)
{
Expand All @@ -166,7 +166,7 @@ const bool UHttpGPTHelper::ModelSupportsChat(const EHttpGPTChatModel& Model)
return false;
}

const FName UHttpGPTHelper::SizeToName(const EHttpGPTImageSize& Size)
const FName UHttpGPTHelper::SizeToName(const EHttpGPTImageSize Size)
{
switch (Size)
{
Expand Down Expand Up @@ -204,7 +204,7 @@ const EHttpGPTImageSize UHttpGPTHelper::NameToSize(const FName Size)
return EHttpGPTImageSize::x256;
}

const FName UHttpGPTHelper::FormatToName(const EHttpGPTResponseFormat& Format)
const FName UHttpGPTHelper::FormatToName(const EHttpGPTResponseFormat Format)
{
switch (Format)
{
Expand Down
12 changes: 6 additions & 6 deletions Source/HttpGPTCommonModule/Public/Utils/HttpGPTHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class HTTPGPTCOMMONMODULE_API UHttpGPTHelper final : public UBlueprintFunctionLi

public:
UFUNCTION(BlueprintPure, Category = "HttpGPT | Chat", meta = (DisplayName = "Convert HttpGPT Model to Name"))
static const FName ModelToName(const EHttpGPTChatModel& Model);
static const FName ModelToName(const EHttpGPTChatModel Model);

UFUNCTION(BlueprintPure, Category = "HttpGPT | Chat", meta = (DisplayName = "Convert Name to HttpGPT Model"))
static const EHttpGPTChatModel NameToModel(const FName Model);

UFUNCTION(BlueprintPure, Category = "HttpGPT | Chat", meta = (DisplayName = "Convert HttpGPT Role to Name"))
static const FName RoleToName(const EHttpGPTChatRole& Role);
static const FName RoleToName(const EHttpGPTChatRole Role);

UFUNCTION(BlueprintPure, Category = "HttpGPT | Chat", meta = (DisplayName = "Convert Name to HttpGPT Role"))
static const EHttpGPTChatRole NameToRole(const FName Role);
Expand All @@ -35,19 +35,19 @@ class HTTPGPTCOMMONMODULE_API UHttpGPTHelper final : public UBlueprintFunctionLi
static const TArray<FName> GetAvailableGPTModels();

UFUNCTION(BlueprintPure, Category = "HttpGPT | Chat", meta = (DisplayName = "Get Endpoint for Model"))
static const FName GetEndpointForModel(const EHttpGPTChatModel& Model);
static const FName GetEndpointForModel(const EHttpGPTChatModel Model);

UFUNCTION(BlueprintPure, Category = "HttpGPT | Chat", meta = (DisplayName = "Model Supports Chat"))
static const bool ModelSupportsChat(const EHttpGPTChatModel& Model);
static const bool ModelSupportsChat(const EHttpGPTChatModel Model);

UFUNCTION(BlueprintPure, Category = "HttpGPT | Image", meta = (DisplayName = "Convert HttpGPT Size to Name"))
static const FName SizeToName(const EHttpGPTImageSize& Size);
static const FName SizeToName(const EHttpGPTImageSize Size);

UFUNCTION(BlueprintPure, Category = "HttpGPT | Image", meta = (DisplayName = "Convert Name to HttpGPT Size"))
static const EHttpGPTImageSize NameToSize(const FName Size);

UFUNCTION(BlueprintPure, Category = "HttpGPT | Image", meta = (DisplayName = "Convert HttpGPT Format to Name"))
static const FName FormatToName(const EHttpGPTResponseFormat& Format);
static const FName FormatToName(const EHttpGPTResponseFormat Format);

UFUNCTION(BlueprintPure, Category = "HttpGPT | Image", meta = (DisplayName = "Convert Name to HttpGPT Format"))
static const EHttpGPTResponseFormat NameToFormat(const FName Format);
Expand Down
28 changes: 18 additions & 10 deletions Source/HttpGPTEditorModule/Private/Chat/SHttpGPTChatItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,35 @@ void SHttpGPTChatItem::Construct(const FArguments& InArgs)
];
}

static FSlateColor& operator*=(FSlateColor& Lhs, const float Rhs)
{
FLinearColor NewColor = Lhs.GetSpecifiedColor() * Rhs;
NewColor.A = 1.f;
Lhs = FSlateColor(NewColor);

return Lhs;
}

TSharedRef<SWidget> SHttpGPTChatItem::ConstructContent()
{
constexpr float SlotPadding = 4.0f;
constexpr float PaddingMultiplier = 16.0f;
constexpr float PaddingMultiplier = 32.0f;

FText RoleText = FText::FromString(TEXT("Undefined:"));
FMargin BoxMargin(SlotPadding);
FText RoleText = FText::FromString(TEXT("User:"));
FMargin BoxMargin(SlotPadding * PaddingMultiplier, SlotPadding, SlotPadding, SlotPadding);
FSlateColor MessageColor(FLinearColor::White);

if (MessageRole == EHttpGPTChatRole::User)
{
RoleText = FText::FromString(TEXT("User:"));
BoxMargin = FMargin(SlotPadding * PaddingMultiplier, SlotPadding, SlotPadding, SlotPadding);
}
else if (MessageRole == EHttpGPTChatRole::Assistant)
if (MessageRole == EHttpGPTChatRole::Assistant)
{
RoleText = FText::FromString(TEXT("Assistant:"));
BoxMargin = FMargin(SlotPadding, SlotPadding, SlotPadding * PaddingMultiplier, SlotPadding);
MessageColor *= 0.3f;
}
else if (MessageRole == EHttpGPTChatRole::System)
{
RoleText = FText::FromString(TEXT("System:"));
BoxMargin = FMargin(SlotPadding * (PaddingMultiplier * 0.5f), SlotPadding);
BoxMargin = FMargin(SlotPadding * PaddingMultiplier * 0.5f, SlotPadding);
MessageColor *= 0.f;
}

const FMargin MessageMargin(SlotPadding * 4.f, SlotPadding, SlotPadding, SlotPadding);
Expand All @@ -77,6 +84,7 @@ TSharedRef<SWidget> SHttpGPTChatItem::ConstructContent()
[
SNew(SBorder)
.BorderImage(FAppStyle::Get().GetBrush("Menu.Background"))
.BorderBackgroundColor(MessageColor)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
Expand Down
4 changes: 3 additions & 1 deletion Source/HttpGPTEditorModule/Private/Chat/SHttpGPTChatItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

#include <CoreMinimal.h>
#include <Widgets/SCompoundWidget.h>
#include "Structures/HttpGPTChatTypes.h"
#include <Structures/HttpGPTChatTypes.h>

static const FName NewSessionName = TEXT("New Session");

class SHttpGPTChatItem final : public SCompoundWidget
{
Expand Down
Loading

0 comments on commit dbe5b06

Please sign in to comment.