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 OpenAIImageSizeGptImage1ToString(EImageSizeGptImage1 ImageSize);
57
58 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
59 static EImageSizeGptImage1 StringToOpenAIImageSizeGptImage1(const FString& ImageSize);
60
61 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
62 static FString OpenAIImageFormatToString(EOpenAIImageFormat ImageFormat);
63
64 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
65 static EOpenAIImageFormat StringToOpenAIImageFormat(const FString& ImageFormat);
66
67 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
68 static FString OpenAIImageQualityToString(EOpenAIImageQuality ImageQuality);
69
70 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
71 static FString OpenAIImageOutputFormatToString(EOpenAIImageOutputFormat ImageOutputFormat);
72
73 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
74 static EOpenAIImageQuality StringToOpenAIImageQuality(const FString& ImageQuality);
75
76 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
77 static FString OpenAIImageBackgroundToString(EOpenAIImageBackground ImageBackground);
78
79 UFUNCTION(BlueprintPure, Category = "OpenAI | Image")
80 static FString OpenAIImageModerationToString(EOpenAIImageModeration ImageModeration);
81
82 UFUNCTION(BlueprintPure, Category = "OpenAI | Chat")
83 static FString OpenAIChatResponseFormatToString(EChatResponseFormat ChatResponseFormat);
84
85 UFUNCTION(BlueprintPure, Category = "OpenAI | Chat")
86 static FString OpenAIMessageContentTypeToString(EMessageContentType MessageContentType);
87
88 UFUNCTION(BlueprintPure, Category = "OpenAI | Chat")
89 static FString OpenAIServiceTierToString(EServiceTier ServiceTier);
90
91 UFUNCTION(BlueprintPure, Category = "OpenAI | Embeddings")
92 static FString OpenAIEmbeddingsEncodingFormatToString(EEmbeddingsEncodingFormat EmbeddingsEncodingFormat);
93
94 UFUNCTION(BlueprintPure, Category = "OpenAI | File")
95 static FString OpenAIUploadFilePurposeToString(EUploadFilePurpose UploadFilePurpose);
96
97 UFUNCTION(BlueprintPure, Category = "OpenAI | Batch")
98 static FString OpenAIBatchEndpointToString(EBatchEndpoint BatchEndpoint);
99
100 UFUNCTION(BlueprintPure, Category = "OpenAI | Batch")
101 static FString OpenAIBatchCompletionWindowToString(EBatchCompletionWindow BatchCompletionWindow);
102
103 UFUNCTION(BlueprintPure, Category = "OpenAI | Upload")
104 static FString OpenAIUploadStatusToString(EUploadStatus UploadStatus);
105
106 UFUNCTION(BlueprintPure, Category = "OpenAI | Upload")
107 static FString OpenAIAssistantToolTypeToString(EAssistantToolType AssistantToolType);
108
109 // video
110 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
111 static FString OpenAIVideoModelToString(EVideoModel VideoModel);
112
113 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
114 static EVideoModel StringToOpenAIVideoModel(const FString& VideoModel);
115
116 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
117 static FString OpenAIVideoStatusToString(EVideoStatus VideoStatus);
118
119 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
120 static EVideoStatus StringToOpenAIVideoStatus(const FString& VideoStatus);
121
122 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
123 static FString OpenAIVideoVariantToString(EVideoVariant VideoVariant);
124
125 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
126 static EVideoVariant StringToOpenAIVideoVariant(const FString& VideoVariant);
127
128 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
129 static FString OpenAIVideoSizeToString(EVideoSize VideoSize);
130
131 UFUNCTION(BlueprintPure, Category = "OpenAI | Video")
132 static EVideoSize StringToOpenAIVideoSize(const FString& VideoSize);
133
134 // common
135 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
136 static FString OpenAIRoleToString(ERole Role);
137
138 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
139 static FString OpenAIFinishReasonToString(EOpenAIFinishReason FinishReason);
140
141 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
142 static EOpenAIFinishReason StringToOpenAIFinishReason(const FString& FinishReason);
143
144 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
145 static ERole StringToOpenAIRole(const FString& Role);
146
147 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
148 static FString OpenAIHeaderTypeToString(EOpenAIHttpHeaderType Type);
149
150 UFUNCTION(BlueprintPure, Category = "OpenAI | Common")
151 static FString FindOpenAIHttpHeaderByType(const FOpenAIResponseMetadata& Headers, EOpenAIHttpHeaderType Type);
152
153 // errors
154 UFUNCTION(BlueprintPure, Category = "OpenAI | Error")
155 static EOpenAIResponseError GetErrorCode(const FString& RawError);
156
157 UFUNCTION(BlueprintPure, Category = "OpenAI | Error")
158 static FString GetErrorMessage(const FString& RawError);
159
160 UFUNCTION(BlueprintPure, Category = "OpenAI | Error")
161 static FString ResponseErrorToString(EOpenAIResponseError Code);
162
163 // base64
164 UFUNCTION(BlueprintPure, Category = "OpenAI | Base64")
165 static FString WrapBase64(const FString& Base64String);
166
167 UFUNCTION(BlueprintPure, Category = "OpenAI | Base64")
168 static FString UnWrapBase64(const FString& Base64String);
169
170 UFUNCTION(BlueprintPure, Category = "OpenAI | Base64")
171 static FString FilePathToBase64(const FString& FilePath);
172
173 // API
180 UFUNCTION(BlueprintPure, Category = "OpenAI | API")
181 static FOpenAIAuth LoadAPITokensFromFile(const FString& FilePath);
182
183 UFUNCTION(BlueprintPure, Category = "OpenAI | API")
184 static FOpenAIAuth LoadAPITokensFromFileOnce(const FString& FilePath);
185
186 // misc helpers
187 static FString BoolToString(bool Value);
188 static FString RemoveWhiteSpaces(const FString& Input);
189 static OpenAI::ServiceSecrets LoadServiceSecretsFromFile(const FString& FilePath);
190 static bool LoadSecretByName(const OpenAI::ServiceSecrets& Secrets, const FString& SecretName, FString& SecretValue);
191 static FString MakeURLWithQuery(const FString& URL, const OpenAI::QueryPairs& Args);
192};
Definition OpenAIFuncLib.h:12
static FOpenAIAuth LoadAPITokensFromFile(const FString &FilePath)
Definition OpenAIFuncLib.cpp:871
Definition ModerationTypes.h:140
Definition OpenAICommonTypes.h:11
Definition ModelTypes.h:174
Definition OpenAICommonTypes.h:49