Unreal OpenAI API 1.0.0
OpenAIFuncLib.h
1// OpenAI Sample, Copyright LifeEXE. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Kismet/BlueprintFunctionLibrary.h"
7#include "Provider/Types/AllTypesHeader.h"
8#include "OpenAIFuncLib.generated.h"
9
10UCLASS()
11class OPENAI_API UOpenAIFuncLib : public UBlueprintFunctionLibrary
12{
13 GENERATED_BODY()
14
15public:
16 UFUNCTION(BlueprintPure, Category = "OpenAI | Model")
17 static FString OpenAIAllModelToString(EAllModelEnum Model);
18
19 UFUNCTION(BlueprintPure, Category = "OpenAI | Model")
20 static FString OpenAIMainModelToString(EMainModelEnum Model);
21
22 UFUNCTION(BlueprintPure, Category = "OpenAI | Model")
23 static FString OpenAIModelToString(const FOpenAIModel& OpenAIModel);
24
25 UFUNCTION(BlueprintPure, Category = "OpenAI | Moderation")
26 static FString OpenAIModerationModelToString(EModerationsModelEnum Model);
27
28 UFUNCTION(BlueprintPure, Category = "OpenAI | Moderations")
29 static FString OpenAIModerationsToString(const FModerationResults& ModerationResults);
30
31 UFUNCTION(BlueprintPure, Category = "OpenAI | Model | Vision")
32 static bool ModelSupportsVision(const FString& Model);
33
34 UFUNCTION(BlueprintPure, Category = "OpenAI| Audio")
35 static FString OpenAIAudioModelToString(EAudioModel Model);
36
37 UFUNCTION(BlueprintPure, Category = "OpenAI| Audio")
38 static FString OpenAITTSModelToString(ETTSModel Model);
39
40 UFUNCTION(BlueprintPure, Category = "OpenAI| Audio")
41 static FString OpenAIVoiceToString(EVoice Voice);
42
43 UFUNCTION(BlueprintPure, Category = "OpenAI| Audio")
44 static FString OpenAITTSAudioFormatToString(ETTSAudioFormat Format);
45
46 UFUNCTION(BlueprintPure, Category = "OpenAI | Audio")
47 static FString OpenAIAudioTranscriptToString(ETranscriptFormat TranscriptFormat);
48
49 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
50 static FString OpenAIImageModelToString(EImageModelEnum Model);
51
52 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
53 static EImageModelEnum StringToOpenAIImageModel(const FString& Model);
54
55 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
56 static FString OpenAIImageSizeDalle2ToString(EImageSizeDalle2 ImageSize);
57
58 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
59 static EImageSizeDalle2 StringToOpenAIImageSizeDalle2(const FString& ImageSize);
60
61 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
62 static FString OpenAIImageSizeDalle3ToString(EImageSizeDalle3 ImageSize);
63
64 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
65 static EImageSizeDalle3 StringToOpenAIImageSizeDalle3(const FString& ImageSize);
66
67 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
68 static FString OpenAIImageSizeGptImage1ToString(EImageSizeGptImage1 ImageSize);
69
70 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
71 static EImageSizeGptImage1 StringToOpenAIImageSizeGptImage1(const FString& ImageSize);
72
73 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
74 static FString OpenAIImageFormatToString(EOpenAIImageFormat ImageFormat);
75
76 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
77 static EOpenAIImageFormat StringToOpenAIImageFormat(const FString& ImageFormat);
78
79 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
80 static FString OpenAIImageQualityToString(EOpenAIImageQuality ImageQuality);
81
82 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
83 static FString OpenAIImageOutputFormatToString(EOpenAIImageOutputFormat ImageOutputFormat);
84
85 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
86 static EOpenAIImageQuality StringToOpenAIImageQuality(const FString& ImageQuality);
87
88 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
89 static FString OpenAIImageStyleToString(EOpenAIImageStyle ImageStyle);
90
91 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
92 static FString OpenAIImageBackgroundToString(EOpenAIImageBackground ImageBackground);
93
94 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
95 static FString OpenAIImageModerationToString(EOpenAIImageModeration ImageModeration);
96
97 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
98 static EOpenAIImageStyle StringToOpenAIImageStyle(const FString& ImageStyle);
99
100 UFUNCTION(BlueprintPure, Category = "OpenAI | Chat")
101 static FString OpenAIChatResponseFormatToString(EChatResponseFormat ChatResponseFormat);
102
103 UFUNCTION(BlueprintPure, Category = "OpenAI | Chat")
104 static FString OpenAIMessageContentTypeToString(EMessageContentType MessageContentType);
105
106 UFUNCTION(BlueprintPure, Category = "OpenAI | Chat")
107 static FString OpenAIServiceTierToString(EServiceTier ServiceTier);
108
109 UFUNCTION(BlueprintPure, Category = "OpenAI | Embeddings")
110 static FString OpenAIEmbeddingsEncodingFormatToString(EEmbeddingsEncodingFormat EmbeddingsEncodingFormat);
111
112 UFUNCTION(BlueprintPure, Category = "OpenAI | File")
113 static FString OpenAIUploadFilePurposeToString(EUploadFilePurpose UploadFilePurpose);
114
115 UFUNCTION(BlueprintPure, Category = "OpenAI | Batch")
116 static FString OpenAIBatchEndpointToString(EBatchEndpoint BatchEndpoint);
117
118 UFUNCTION(BlueprintPure, Category = "OpenAI | Batch")
119 static FString OpenAIBatchCompletionWindowToString(EBatchCompletionWindow BatchCompletionWindow);
120
121 UFUNCTION(BlueprintPure, Category = "OpenAI | Upload")
122 static FString OpenAIUploadStatusToString(EUploadStatus UploadStatus);
123
124 UFUNCTION(BlueprintPure, Category = "OpenAI | Upload")
125 static FString OpenAIAssistantToolTypeToString(EAssistantToolType AssistantToolType);
126
127 // common
128 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
129 static FString OpenAIRoleToString(ERole Role);
130
131 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
132 static FString OpenAIFinishReasonToString(EOpenAIFinishReason FinishReason);
133
134 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
135 static EOpenAIFinishReason StringToOpenAIFinishReason(const FString& FinishReason);
136
137 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
138 static ERole StringToOpenAIRole(const FString& Role);
139
140 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
141 static FString OpenAIHeaderTypeToString(EOpenAIHttpHeaderType Type);
142
143 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
144 static FString FindOpenAIHttpHeaderByType(const FOpenAIResponseMetadata& Headers, EOpenAIHttpHeaderType Type);
145
146 // errors
147 UFUNCTION(BlueprintPure, Category = "OpenAI | Error")
148 static EOpenAIResponseError GetErrorCode(const FString& RawError);
149
150 UFUNCTION(BlueprintPure, Category = "OpenAI | Error")
151 static FString GetErrorMessage(const FString& RawError);
152
153 UFUNCTION(BlueprintPure, Category = "OpenAI | Error")
154 static FString ResponseErrorToString(EOpenAIResponseError Code);
155
156 // base64
157 UFUNCTION(BlueprintPure, Category = "OpenAI | Base64")
158 static FString WrapBase64(const FString& Base64String);
159
160 UFUNCTION(BlueprintPure, Category = "OpenAI | Base64")
161 static FString UnWrapBase64(const FString& Base64String);
162
163 UFUNCTION(BlueprintPure, Category = "OpenAI | Base64")
164 static FString FilePathToBase64(const FString& FilePath);
165
166 // API
173 UFUNCTION(BlueprintPure, Category = "OpenAI | API")
174 static FOpenAIAuth LoadAPITokensFromFile(const FString& FilePath);
175
176 UFUNCTION(BlueprintPure, Category = "OpenAI | API")
177 static FOpenAIAuth LoadAPITokensFromFileOnce(const FString& FilePath);
178
179 // misc helpers
180 static FString BoolToString(bool Value);
181 static FString RemoveWhiteSpaces(const FString& Input);
182 static OpenAI::ServiceSecrets LoadServiceSecretsFromFile(const FString& FilePath);
183 static bool LoadSecretByName(const OpenAI::ServiceSecrets& Secrets, const FString& SecretName, FString& SecretValue);
184 static FString MakeURLWithQuery(const FString& URL, const OpenAI::QueryPairs& Args);
185};
Definition: OpenAIFuncLib.h:12
Definition: ModerationTypes.h:126
Definition: CommonTypes.h:11
Definition: ModelTypes.h:120
Definition: CommonTypes.h:49