diff --git a/Standard.AI.OpenAI/Brokers/OpenAIs/IOpenAIBroker.Files.cs b/Standard.AI.OpenAI/Brokers/OpenAIs/IOpenAIBroker.Files.cs index 18ef004c..f69b9152 100644 --- a/Standard.AI.OpenAI/Brokers/OpenAIs/IOpenAIBroker.Files.cs +++ b/Standard.AI.OpenAI/Brokers/OpenAIs/IOpenAIBroker.Files.cs @@ -10,5 +10,6 @@ namespace Standard.AI.OpenAI.Brokers.OpenAIs internal partial interface IOpenAIBroker { ValueTask DeleteFileByIdAsync(string fileId); + ValueTask UploadFileAsync(ExternalUploadFileRequest request); } } \ No newline at end of file diff --git a/Standard.AI.OpenAI/Brokers/OpenAIs/OpenAIBroker.Files.cs b/Standard.AI.OpenAI/Brokers/OpenAIs/OpenAIBroker.Files.cs index 4555daa2..30f76935 100644 --- a/Standard.AI.OpenAI/Brokers/OpenAIs/OpenAIBroker.Files.cs +++ b/Standard.AI.OpenAI/Brokers/OpenAIs/OpenAIBroker.Files.cs @@ -11,5 +11,9 @@ internal partial class OpenAIBroker { public async ValueTask DeleteFileByIdAsync(string fileId) => await DeleteAsync(relativeUrl: $"v1/files/{fileId}"); + + public async ValueTask UploadFileAsync( + ExternalUploadFileRequest request) => + await PostAsync(relativeUrl: "v1/files", request); } } \ No newline at end of file diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ExternalFiles/ExternalUploadFileRequest.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ExternalFiles/ExternalUploadFileRequest.cs new file mode 100644 index 00000000..88969c80 --- /dev/null +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ExternalFiles/ExternalUploadFileRequest.cs @@ -0,0 +1,17 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization, a coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Newtonsoft.Json; + +namespace Standard.AI.OpenAI.Models.Services.Foundations.ExternalFiles +{ + internal class ExternalUploadFileRequest + { + [JsonProperty(propertyName: "file")] + public string File { get; set; } + + [JsonProperty(propertyName: "purpose")] + public string Purpose { get; set; } + } +} diff --git a/Standard.AI.OpenAI/Models/Services/Foundations/ExternalFiles/ExternalUploadFileResponse.cs b/Standard.AI.OpenAI/Models/Services/Foundations/ExternalFiles/ExternalUploadFileResponse.cs new file mode 100644 index 00000000..809d1705 --- /dev/null +++ b/Standard.AI.OpenAI/Models/Services/Foundations/ExternalFiles/ExternalUploadFileResponse.cs @@ -0,0 +1,29 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization, a coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Newtonsoft.Json; + +namespace Standard.AI.OpenAI.Models.Services.Foundations.ExternalFiles +{ + internal class ExternalUploadFileResponse + { + [JsonProperty(propertyName: "id")] + public string Id { get; set; } + + [JsonProperty(propertyName: "object")] + public string Object { get; set; } + + [JsonProperty(propertyName: "bytes")] + public int Bytes { get; set; } + + [JsonProperty(propertyName: "created_at")] + public long CreatedAt { get; set; } + + [JsonProperty(propertyName: "filename")] + public string FileName { get; set; } + + [JsonProperty(propertyName: "purpose")] + public string Purpose { get; set; } + } +}