Skip to content

Commit d2a258a

Browse files
authored
Merge pull request #75 from srcnalt/feature/warning-field
Warning Field in Data Types
2 parents cb89f5a + b8d13cf commit d2a258a

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

Runtime/DataTypes.cs

+15
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class OpenAIFile
3434
public class OpenAIFileResponse : OpenAIFile, IResponse
3535
{
3636
public ApiError Error { get; set; }
37+
public string Warning { get; set; }
3738
}
3839

3940
public class ApiError
@@ -56,6 +57,7 @@ public struct Auth
5657
public struct ListModelsResponse: IResponse
5758
{
5859
public ApiError Error { get; set; }
60+
public string Warning { get; set; }
5961
public string Object { get; set; }
6062
public List<OpenAIModel> Data { get; set; }
6163
}
@@ -74,6 +76,7 @@ public class OpenAIModel
7476
public class OpenAIModelResponse : OpenAIModel, IResponse
7577
{
7678
public ApiError Error { get; set; }
79+
public string Warning { get; set; }
7780
}
7881
#endregion
7982

@@ -96,6 +99,7 @@ public sealed class CreateChatCompletionRequest
9699
public struct CreateChatCompletionResponse : IResponse
97100
{
98101
public ApiError Error { get; set; }
102+
public string Warning { get; set; }
99103
public string Model { get; set; }
100104
public string Id { get; set; }
101105
public string Object { get; set; }
@@ -148,6 +152,7 @@ public class CreateAudioTranslationRequest: CreateAudioRequestBase { }
148152
public struct CreateAudioResponse: IResponse
149153
{
150154
public ApiError Error { get; set; }
155+
public string Warning { get; set; }
151156
public string Text { get; set; }
152157
}
153158
#endregion
@@ -176,6 +181,7 @@ public sealed class CreateCompletionRequest
176181
public struct CreateCompletionResponse: IResponse
177182
{
178183
public ApiError Error { get; set; }
184+
public string Warning { get; set; }
179185
public string Id { get; set; }
180186
public string Object { get; set; }
181187
public long Created { get; set; }
@@ -199,6 +205,7 @@ public sealed class CreateEditRequest
199205
public struct CreateEditResponse: IResponse
200206
{
201207
public ApiError Error { get; set; }
208+
public string Warning { get; set; }
202209
public string Object { get; set; }
203210
public long Created { get; set; }
204211
public List<Choice> Choices { get; set; }
@@ -235,6 +242,7 @@ public sealed class CreateImageVariationRequest: CreateImageRequestBase
235242
public struct CreateImageResponse: IResponse
236243
{
237244
public ApiError Error { get; set; }
245+
public string Warning { get; set; }
238246
public long Created { get; set; }
239247
public List<ImageData> Data { get; set; }
240248
}
@@ -257,6 +265,7 @@ public struct CreateEmbeddingsRequest
257265
public struct CreateEmbeddingsResponse: IResponse
258266
{
259267
public ApiError Error { get; set; }
268+
public string Warning { get; set; }
260269
public string Object { get; set; }
261270
public List<EmbeddingData> Data;
262271
public string Model { get; set; }
@@ -275,13 +284,15 @@ public struct EmbeddingData
275284
public struct ListFilesResponse: IResponse
276285
{
277286
public ApiError Error { get; set; }
287+
public string Warning { get; set; }
278288
public string Object { get; set; }
279289
public List<OpenAIFile> Data { get; set; }
280290
}
281291

282292
public struct DeleteResponse: IResponse
283293
{
284294
public ApiError Error { get; set; }
295+
public string Warning { get; set; }
285296
public string Id { get; set; }
286297
public string Object { get; set; }
287298
public bool Deleted { get; set; }
@@ -314,13 +325,15 @@ public class CreateFineTuneRequest
314325
public struct ListFineTunesResponse: IResponse
315326
{
316327
public ApiError Error { get; set; }
328+
public string Warning { get; set; }
317329
public string Object { get; set; }
318330
public List<FineTune> Data { get; set; }
319331
}
320332

321333
public struct ListFineTuneEventsResponse: IResponse
322334
{
323335
public ApiError Error { get; set; }
336+
public string Warning { get; set; }
324337
public string Object { get; set; }
325338
public List<FineTuneEvent> Data { get; set; }
326339
}
@@ -345,6 +358,7 @@ public class FineTune
345358
public class FineTuneResponse : FineTune, IResponse
346359
{
347360
public ApiError Error { get; set; }
361+
public string Warning { get; set; }
348362
}
349363

350364
public struct FineTuneEvent
@@ -366,6 +380,7 @@ public class CreateModerationRequest
366380
public struct CreateModerationResponse: IResponse
367381
{
368382
public ApiError Error { get; set; }
383+
public string Warning { get; set; }
369384
public string Id { get; set; }
370385
public string Model { get; set; }
371386
public List<ModerationResult> Results { get; set; }

Runtime/Interfaces/IResponse.cs

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ namespace OpenAI
33
public interface IResponse
44
{
55
ApiError Error { get; set; }
6+
public string Warning { get; set; }
67
}
78
}

Runtime/OpenAIApi.cs

+5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ private async Task<T> DispatchRequest<T>(string path, string method, byte[] payl
8787
ApiError error = data.Error;
8888
Debug.LogError($"Error Message: {error.Message}\nError Type: {error.Type}\n");
8989
}
90+
91+
if (data?.Warning != null)
92+
{
93+
Debug.LogWarning(data.Warning);
94+
}
9095

9196
return data;
9297
}

Samples~/ChatGPT/ChatGPT.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private async void SendReply()
5858
// Complete the instruction
5959
var completionResponse = await openai.CreateChatCompletion(new CreateChatCompletionRequest()
6060
{
61-
Model = "gpt-3.5-turbo-0301",
61+
Model = "gpt-3.5-turbo-0613",
6262
Messages = messages
6363
});
6464

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.srcnalt.openai-unity",
3-
"version": "0.1.14",
3+
"version": "0.1.15",
44
"displayName": "OpenAI Unity",
55
"description": "An unofficial OpenAI Unity Package that aims to help you use OpenAI API directly in Unity Game engine.",
66
"unity": "2020.3",

0 commit comments

Comments
 (0)