Unreal OpenAI API 1.0.0
Loading...
Searching...
No Matches
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 // video
128 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
129 static FString OpenAIVideoModelToString(EVideoModel VideoModel);
130
131 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
132 static EVideoModel StringToOpenAIVideoModel(const FString& VideoModel);
133
134 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
135 static FString OpenAIVideoStatusToString(EVideoStatus VideoStatus);
136
137 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
138 static EVideoStatus StringToOpenAIVideoStatus(const FString& VideoStatus);
139
140 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
141 static FString OpenAIVideoVariantToString(EVideoVariant VideoVariant);
142
143 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
144 static EVideoVariant StringToOpenAIVideoVariant(const FString& VideoVariant);
145
146 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
147 static FString OpenAIVideoSizeToString(EVideoSize VideoSize);
148
149 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
150 static EVideoSize StringToOpenAIVideoSize(const FString& VideoSize);
151
152 // common
153 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
154 static FString OpenAIRoleToString(ERole Role);
155
156 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
157 static FString OpenAIFinishReasonToString(EOpenAIFinishReason FinishReason);
158
159 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
160 static EOpenAIFinishReason StringToOpenAIFinishReason(const FString& FinishReason);
161
162 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
163 static ERole StringToOpenAIRole(const FString& Role);
164
165 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
166 static FString OpenAIHeaderTypeToString(EOpenAIHttpHeaderType Type);
167
168 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
169 static FString FindOpenAIHttpHeaderByType(const FOpenAIResponseMetadata& Headers, EOpenAIHttpHeaderType Type);
170
171 // errors
172 UFUNCTION(BlueprintPure, Category = "OpenAI | Error")
173 static EOpenAIResponseError GetErrorCode(const FString& RawError);
174
175 UFUNCTION(BlueprintPure, Category = "OpenAI | Error")
176 static FString GetErrorMessage(const FString& RawError);
177
178 UFUNCTION(BlueprintPure, Category = "OpenAI | Error")
179 static FString ResponseErrorToString(EOpenAIResponseError Code);
180
181 // base64
182 UFUNCTION(BlueprintPure, Category = "OpenAI | Base64")
183 static FString WrapBase64(const FString& Base64String);
184
185 UFUNCTION(BlueprintPure, Category = "OpenAI | Base64")
186 static FString UnWrapBase64(const FString& Base64String);
187
188 UFUNCTION(BlueprintPure, Category = "OpenAI | Base64")
189 static FString FilePathToBase64(const FString& FilePath);
190
191 // API
198 UFUNCTION(BlueprintPure, Category = "OpenAI | API")
199 static FOpenAIAuth LoadAPITokensFromFile(const FString& FilePath);
200
201 UFUNCTION(BlueprintPure, Category = "OpenAI | API")
202 static FOpenAIAuth LoadAPITokensFromFileOnce(const FString& FilePath);
203
204 // misc helpers
205 static FString BoolToString(bool Value);
206 static FString RemoveWhiteSpaces(const FString& Input);
207 static OpenAI::ServiceSecrets LoadServiceSecretsFromFile(const FString& FilePath);
208 static bool LoadSecretByName(const OpenAI::ServiceSecrets& Secrets, const FString& SecretName, FString& SecretValue);
209 static FString MakeURLWithQuery(const FString& URL, const OpenAI::QueryPairs& Args);
210};
Definition OpenAIFuncLib.h:12
static FOpenAIAuth LoadAPITokensFromFile(const FString &FilePath)
Definition OpenAIFuncLib.cpp:935
Definition ModerationTypes.h:140
Definition OpenAICommonTypes.h:11
Definition ModelTypes.h:162
Definition OpenAICommonTypes.h:49