Unreal OpenAI API 1.0.0
CompletionAction.h
1// OpenAI, Copyright LifeEXE. All Rights Reserved.
2
3#pragma once
4
5#include "Kismet/BlueprintAsyncActionBase.h"
6#include "Provider/Types/Legacy/CompletionTypes.h"
7#include "Provider/Types/CommonTypes.h"
8#include "CompletionAction.generated.h"
9
10USTRUCT(BlueprintType)
12{
13 GENERATED_BODY()
14
15
16 UPROPERTY(BlueprintReadOnly, Category = "OpenAI")
18
20 UPROPERTY(BlueprintReadOnly, Category = "OpenAI")
21 TArray<FCompletionStreamResponse> StreamResponse;
22
24 UPROPERTY(BlueprintReadOnly, Category = "OpenAI")
25 FString StreamResponseString{};
26
27 UPROPERTY(BlueprintReadOnly, Category = "OpenAI")
28 bool bStream{};
29
30 UPROPERTY(BlueprintReadOnly, Category = "OpenAI")
31 bool bCompleted{};
32};
33
34DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(
35 FOnCompletion, const FCompletionPayload&, Payload, const FOpenAIResponseMetadata&, ResponseMetadata, const FOpenAIError&, RawError);
36
37class UOpenAIProvider;
38
39UCLASS()
40class UCompletionAction : public UBlueprintAsyncActionBase
41{
42 GENERATED_BODY()
43
44public:
45 UPROPERTY(BlueprintAssignable)
46 FOnCompletion OnUpdate;
47
48 virtual void Activate() override;
49
50private:
55 UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"), Category = "OpenAI | Completion")
56 static UCompletionAction* CreateCompletion(const FCompletion& CompletionRequest, const FOpenAIAuth& Auth, const FString& URLOverride);
57
58 void TryToOverrideURL(UOpenAIProvider* Provider);
59
60 void OnCreateCompletionCompleted(const FCompletionResponse& Response, const FOpenAIResponseMetadata& ResponseMetadata);
61 void OnCreateCompletionStreamProgresses(
62 const TArray<FCompletionStreamResponse>& Responses, const FOpenAIResponseMetadata& ResponseMetadata);
63 void OnCreateCompletionStreamCompleted(
64 const TArray<FCompletionStreamResponse>& Responses, const FOpenAIResponseMetadata& ResponseMetadata);
65 void OnRequestError(const FString& URL, const FString& Content);
66
67private:
68 FCompletion Completion;
69 FOpenAIAuth Auth;
70 FString URLOverride{};
71};
Definition: OpenAI.Build.cs:6
Definition: CompletionAction.h:41
Definition: OpenAIProvider.h:45
void CreateCompletion(const FCompletion &Completion, const FOpenAIAuth &Auth)
Definition: OpenAIProvider.cpp:55
Definition: CompletionTypes.h:16
Definition: CompletionAction.h:12
Definition: CompletionTypes.h:252
Definition: CompletionTypes.h:264
Definition: CommonTypes.h:11
Definition: CommonTypes.h:28
Definition: CommonTypes.h:49