OpenAIFileStore
Namespace: Vercel.AI.OpenAI
public sealed class OpenAIFileStore : IFileStoreOpenAI file store.
Inheritance: object
Implements: IFileStore
Constructors
Section titled “Constructors”OpenAIFileStore(OpenAIProvider)
Section titled “OpenAIFileStore(OpenAIProvider)”public OpenAIFileStore(OpenAIProvider provider)Creates a file store.
Parameters
| Name | Type | Description |
|---|---|---|
provider |
OpenAIProvider |
Properties
Section titled “Properties”Provider
Section titled “Provider”public string Provider { get; }Provider id.
Value: string
SpecificationVersion
Section titled “SpecificationVersion”public string SpecificationVersion { get; }Specification version.
Value: string
Methods
Section titled “Methods”DeleteAsync(OpenAIFileReference, CancellationToken)
Section titled “DeleteAsync(OpenAIFileReference, CancellationToken)”public Task DeleteAsync(OpenAIFileReference file, CancellationToken cancellationToken)Deletes a file.
Parameters
| Name | Type | Description |
|---|---|---|
file |
OpenAIFileReference | |
cancellationToken |
CancellationToken |
Returns: Task
DownloadAsync(OpenAIFileReference, CancellationToken)
Section titled “DownloadAsync(OpenAIFileReference, CancellationToken)”public Task<(byte[] Data, string? MediaType)> DownloadAsync(OpenAIFileReference file, CancellationToken cancellationToken)Downloads file bytes. The media type has parameters removed.
Parameters
| Name | Type | Description |
|---|---|---|
file |
OpenAIFileReference | |
cancellationToken |
CancellationToken |
Returns: Task<(byte[] Data, string MediaType)>
GetMetadataAsync(OpenAIFileReference, CancellationToken)
Section titled “GetMetadataAsync(OpenAIFileReference, CancellationToken)”public Task<OpenAIFileMetadata> GetMetadataAsync(OpenAIFileReference file, CancellationToken cancellationToken)Reads file metadata.
Parameters
| Name | Type | Description |
|---|---|---|
file |
OpenAIFileReference | |
cancellationToken |
CancellationToken |
Returns: Task<OpenAIFileMetadata>
RequireId(OpenAIFileReference)
Section titled “RequireId(OpenAIFileReference)”public static string RequireId(OpenAIFileReference file)Returns the OpenAI file id or throws when it is missing.
Parameters
| Name | Type | Description |
|---|---|---|
file |
OpenAIFileReference |
Returns: string
UploadAsync(Stream, string?, string, string?, int?, CancellationToken)
Section titled “UploadAsync(Stream, string?, string, string?, int?, CancellationToken)”public Task<OpenAIFileMetadata> UploadAsync(Stream data, string? fileName, string mediaType, string? purpose, int? expiresAfterSeconds, CancellationToken cancellationToken)Uploads a file from a stream without buffering it, and disposes the stream.
The fields precede the file part, and the file name defaults to blob.
Parameters
| Name | Type | Description |
|---|---|---|
data |
Stream | |
fileName |
string | |
mediaType |
string | |
purpose |
string | |
expiresAfterSeconds |
int? | |
cancellationToken |
CancellationToken |
Returns: Task<OpenAIFileMetadata>
UploadAsync(string, byte[], string, string?, int?, CancellationToken)
Section titled “UploadAsync(string, byte[], string, string?, int?, CancellationToken)”public Task<OpenAIFileMetadata> UploadAsync(string fileName, byte[] data, string mediaType, string? purpose, int? expiresAfterSeconds, CancellationToken cancellationToken)Uploads a file. <code class=“paramref”>expiresAfterSeconds</code> sends expires_after.
Parameters
| Name | Type | Description |
|---|---|---|
fileName |
string | |
data |
byte[] | |
mediaType |
string | |
purpose |
string | |
expiresAfterSeconds |
int? | |
cancellationToken |
CancellationToken |
Returns: Task<OpenAIFileMetadata>
UploadFileAsync(string, byte[], string, CancellationToken)
Section titled “UploadFileAsync(string, byte[], string, CancellationToken)”public Task<UploadedFile> UploadFileAsync(string fileName, byte[] data, string mediaType, CancellationToken cancellationToken)Uploads a file.
Parameters
| Name | Type | Description |
|---|---|---|
fileName |
string | |
data |
byte[] | |
mediaType |
string | |
cancellationToken |
CancellationToken |
Returns: Task<UploadedFile>
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product