Skip to content

Commit

Permalink
Merge pull request #75 from srcnalt/feature/warning-field
Browse files Browse the repository at this point in the history
Warning Field in Data Types
  • Loading branch information
srcnalt authored Jul 17, 2023
2 parents cb89f5a + b8d13cf commit d2a258a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Runtime/DataTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class OpenAIFile
public class OpenAIFileResponse : OpenAIFile, IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
}

public class ApiError
Expand All @@ -56,6 +57,7 @@ public struct Auth
public struct ListModelsResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Object { get; set; }
public List<OpenAIModel> Data { get; set; }
}
Expand All @@ -74,6 +76,7 @@ public class OpenAIModel
public class OpenAIModelResponse : OpenAIModel, IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
}
#endregion

Expand All @@ -96,6 +99,7 @@ public sealed class CreateChatCompletionRequest
public struct CreateChatCompletionResponse : IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Model { get; set; }
public string Id { get; set; }
public string Object { get; set; }
Expand Down Expand Up @@ -148,6 +152,7 @@ public class CreateAudioTranslationRequest: CreateAudioRequestBase { }
public struct CreateAudioResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Text { get; set; }
}
#endregion
Expand Down Expand Up @@ -176,6 +181,7 @@ public sealed class CreateCompletionRequest
public struct CreateCompletionResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Id { get; set; }
public string Object { get; set; }
public long Created { get; set; }
Expand All @@ -199,6 +205,7 @@ public sealed class CreateEditRequest
public struct CreateEditResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Object { get; set; }
public long Created { get; set; }
public List<Choice> Choices { get; set; }
Expand Down Expand Up @@ -235,6 +242,7 @@ public sealed class CreateImageVariationRequest: CreateImageRequestBase
public struct CreateImageResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public long Created { get; set; }
public List<ImageData> Data { get; set; }
}
Expand All @@ -257,6 +265,7 @@ public struct CreateEmbeddingsRequest
public struct CreateEmbeddingsResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Object { get; set; }
public List<EmbeddingData> Data;
public string Model { get; set; }
Expand All @@ -275,13 +284,15 @@ public struct EmbeddingData
public struct ListFilesResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Object { get; set; }
public List<OpenAIFile> Data { get; set; }
}

public struct DeleteResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Id { get; set; }
public string Object { get; set; }
public bool Deleted { get; set; }
Expand Down Expand Up @@ -314,13 +325,15 @@ public class CreateFineTuneRequest
public struct ListFineTunesResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Object { get; set; }
public List<FineTune> Data { get; set; }
}

public struct ListFineTuneEventsResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Object { get; set; }
public List<FineTuneEvent> Data { get; set; }
}
Expand All @@ -345,6 +358,7 @@ public class FineTune
public class FineTuneResponse : FineTune, IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
}

public struct FineTuneEvent
Expand All @@ -366,6 +380,7 @@ public class CreateModerationRequest
public struct CreateModerationResponse: IResponse
{
public ApiError Error { get; set; }
public string Warning { get; set; }
public string Id { get; set; }
public string Model { get; set; }
public List<ModerationResult> Results { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Runtime/Interfaces/IResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ namespace OpenAI
public interface IResponse
{
ApiError Error { get; set; }
public string Warning { get; set; }
}
}
5 changes: 5 additions & 0 deletions Runtime/OpenAIApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ private async Task<T> DispatchRequest<T>(string path, string method, byte[] payl
ApiError error = data.Error;
Debug.LogError($"Error Message: {error.Message}\nError Type: {error.Type}\n");
}

if (data?.Warning != null)
{
Debug.LogWarning(data.Warning);
}

return data;
}
Expand Down
2 changes: 1 addition & 1 deletion Samples~/ChatGPT/ChatGPT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private async void SendReply()
// Complete the instruction
var completionResponse = await openai.CreateChatCompletion(new CreateChatCompletionRequest()
{
Model = "gpt-3.5-turbo-0301",
Model = "gpt-3.5-turbo-0613",
Messages = messages
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.srcnalt.openai-unity",
"version": "0.1.14",
"version": "0.1.15",
"displayName": "OpenAI Unity",
"description": "An unofficial OpenAI Unity Package that aims to help you use OpenAI API directly in Unity Game engine.",
"unity": "2020.3",
Expand Down

0 comments on commit d2a258a

Please sign in to comment.