Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BROKERS: Upload File #351

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Standard.AI.OpenAI/Brokers/OpenAIs/IOpenAIBroker.Files.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ namespace Standard.AI.OpenAI.Brokers.OpenAIs
internal partial interface IOpenAIBroker
{
ValueTask<ExternalFile> DeleteFileByIdAsync(string fileId);
ValueTask<ExternalUploadFileResponse> UploadFileAsync(ExternalUploadFileRequest request);
}
}
4 changes: 4 additions & 0 deletions Standard.AI.OpenAI/Brokers/OpenAIs/OpenAIBroker.Files.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ internal partial class OpenAIBroker
{
public async ValueTask<ExternalFile> DeleteFileByIdAsync(string fileId) =>
await DeleteAsync<ExternalFile>(relativeUrl: $"v1/files/{fileId}");

public async ValueTask<ExternalUploadFileResponse> UploadFileAsync(
ExternalUploadFileRequest request) =>
await PostAsync<ExternalUploadFileRequest,ExternalUploadFileResponse>(relativeUrl: "v1/files", request);
}
}
Original file line number Diff line number Diff line change
@@ -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; }
}
}
Original file line number Diff line number Diff line change
@@ -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; }
}
}