Unreal OpenAI API 1.0.0
ChatGPTWorld.h
1// OpenAI, Copyright LifeEXE. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "GameFramework/Info.h"
7#include "Provider/Types/CommonTypes.h"
8#include "Provider/Types/ModelTypes.h"
9#include "Provider/Types/Chat/ChatCompletionChunkTypes.h"
10#include "ChatGPTWorld.generated.h"
11
12DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnGPTRequestUpdated, const FMessage&, Message);
13DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnGPTRequestCompleted, const FMessage&, Message);
14
15class UChatGPT;
16
17UCLASS(Blueprintable, BlueprintType)
18class OPENAI_API AChatGPTWorld : public AInfo
19{
20 GENERATED_BODY()
21
22protected:
23 virtual void BeginPlay() override;
24
25 UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "OpenAI")
26 EMainModelEnum Model{EMainModelEnum::O1};
27
28 UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "OpenAI")
29 int32 MaxTokens{2000};
30
31 UFUNCTION(BlueprintCallable, Category = "OpenAI")
32 void SetAuth(const FOpenAIAuth& OpenAIAuth);
33
34 UFUNCTION(BlueprintCallable, Category = "OpenAI")
35 void SetModel(const FString& ModelName);
36
37 UFUNCTION(BlueprintCallable, Category = "OpenAI")
38 bool IsInProgress() const { return bIsInProgress; }
39
40 UFUNCTION(BlueprintCallable, Category = "OpenAI")
41 void MakeRequest(const FMessage& Message);
42
43 UFUNCTION(BlueprintCallable, Category = "OpenAI")
44 FMessage GetLastMessage() const { return LastMessage; }
45
46protected:
47 UPROPERTY(BlueprintAssignable)
48 FOnGPTRequestUpdated OnGPTRequestUpdated;
49
50 UPROPERTY(BlueprintAssignable)
51 FOnGPTRequestCompleted OnGPTRequestCompleted;
52
53private:
54 FOpenAIAuth OpenAIAuth;
55
56 UPROPERTY()
57 TObjectPtr<UChatGPT> ChatGPT;
58
59 bool bIsInProgress{false};
60 FMessage LastMessage;
61
62private:
63 void OnRequestCompleted();
64 void OnRequestUpdated(const FMessage& Message, bool WasError);
65};
Definition: ChatGPTWorld.h:19
Definition: ChatGPT.h:21
Definition: ChatCommonTypes.h:75
Definition: CommonTypes.h:11