Skip to content
Merged
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
2 changes: 1 addition & 1 deletion codegen/generator/src/OpenAI.Library.Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20251022.4" />
<PackageReference Include="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20251031.1" />
</ItemGroup>

<!-- Copy output to package dist path for local execution and -->
Expand Down
2 changes: 1 addition & 1 deletion codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@open-ai/plugin": "file:",
"@azure-tools/typespec-client-generator-core": "0.61.0",
"@typespec/http-client-csharp": "1.0.0-alpha.20251022.4",
"@typespec/http-client-csharp": "1.0.0-alpha.20251031.1",
"@typespec/http": "1.5.0",
"@typespec/openapi": "1.5.0"
},
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Custom/Internal/CancellationTokenExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace OpenAI;

internal static class CancellationTokenExtensions
internal static partial class CancellationTokenExtensions
{
public static RequestOptions ToRequestOptions(this CancellationToken cancellationToken, bool streaming = false)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Generated/AssistantClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public virtual CollectionResult<Assistant> GetAssistants(AssistantCollectionOpti
options?.Order?.ToString(),
options?.AfterId,
options?.BeforeId,
cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
cancellationToken.ToRequestOptions());
}

public virtual AsyncCollectionResult<Assistant> GetAssistantsAsync(AssistantCollectionOptions options = default, CancellationToken cancellationToken = default)
Expand All @@ -64,7 +64,7 @@ public virtual AsyncCollectionResult<Assistant> GetAssistantsAsync(AssistantColl
options?.Order?.ToString(),
options?.AfterId,
options?.BeforeId,
cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
cancellationToken.ToRequestOptions());
}

public virtual ClientResult CreateAssistant(BinaryContent content, RequestOptions options = null)
Expand Down
4 changes: 2 additions & 2 deletions src/Generated/BatchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public virtual AsyncCollectionResult GetBatchesAsync(string after, int? limit, R

public virtual CollectionResult<BatchJob> GetBatches(BatchCollectionOptions options = default, CancellationToken cancellationToken = default)
{
return new BatchClientGetBatchesCollectionResultOfT(this, options?.AfterId, options?.PageSizeLimit, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
return new BatchClientGetBatchesCollectionResultOfT(this, options?.AfterId, options?.PageSizeLimit, cancellationToken.ToRequestOptions());
}

public virtual AsyncCollectionResult<BatchJob> GetBatchesAsync(BatchCollectionOptions options = default, CancellationToken cancellationToken = default)
{
return new BatchClientGetBatchesAsyncCollectionResultOfT(this, options?.AfterId, options?.PageSizeLimit, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
return new BatchClientGetBatchesAsyncCollectionResultOfT(this, options?.AfterId, options?.PageSizeLimit, cancellationToken.ToRequestOptions());
}

public virtual ClientResult GetBatch(string batchId, RequestOptions options)
Expand Down
8 changes: 4 additions & 4 deletions src/Generated/ChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public virtual CollectionResult<ChatCompletion> GetChatCompletions(ChatCompletio
options?.Order?.ToString(),
options?.Metadata,
options?.Model,
cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
cancellationToken.ToRequestOptions());
}

[Experimental("OPENAI001")]
Expand All @@ -72,7 +72,7 @@ public virtual AsyncCollectionResult<ChatCompletion> GetChatCompletionsAsync(Cha
options?.Order?.ToString(),
options?.Metadata,
options?.Model,
cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
cancellationToken.ToRequestOptions());
}

public virtual ClientResult CompleteChat(BinaryContent content, RequestOptions options = null)
Expand Down Expand Up @@ -186,7 +186,7 @@ public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletio
options?.AfterId,
options?.PageSizeLimit,
options?.Order?.ToString(),
cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
cancellationToken.ToRequestOptions());
}

[Experimental("OPENAI001")]
Expand All @@ -200,7 +200,7 @@ public virtual AsyncCollectionResult<ChatCompletionMessageListDatum> GetChatComp
options?.AfterId,
options?.PageSizeLimit,
options?.Order?.ToString(),
cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
cancellationToken.ToRequestOptions());
}
}
}
32 changes: 16 additions & 16 deletions src/Generated/ContainerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public virtual AsyncCollectionResult GetContainersAsync(int? limit, string order

public virtual CollectionResult<ContainerResource> GetContainers(ContainerCollectionOptions options = default, CancellationToken cancellationToken = default)
{
return new ContainerClientGetContainersCollectionResultOfT(this, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
return new ContainerClientGetContainersCollectionResultOfT(this, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, cancellationToken.ToRequestOptions());
}

public virtual AsyncCollectionResult<ContainerResource> GetContainersAsync(ContainerCollectionOptions options = default, CancellationToken cancellationToken = default)
{
return new ContainerClientGetContainersAsyncCollectionResultOfT(this, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
return new ContainerClientGetContainersAsyncCollectionResultOfT(this, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, cancellationToken.ToRequestOptions());
}

public virtual ClientResult CreateContainer(BinaryContent content, RequestOptions options = null)
Expand All @@ -63,15 +63,15 @@ public virtual ClientResult<ContainerResource> CreateContainer(CreateContainerBo
{
Argument.AssertNotNull(body, nameof(body));

ClientResult result = CreateContainer(body, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
ClientResult result = CreateContainer(body, cancellationToken.ToRequestOptions());
return ClientResult.FromValue((ContainerResource)result, result.GetRawResponse());
}

public virtual async Task<ClientResult<ContainerResource>> CreateContainerAsync(CreateContainerBody body, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(body, nameof(body));

ClientResult result = await CreateContainerAsync(body, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false);
ClientResult result = await CreateContainerAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
return ClientResult.FromValue((ContainerResource)result, result.GetRawResponse());
}

Expand All @@ -95,15 +95,15 @@ public virtual ClientResult<ContainerResource> GetContainer(string containerId,
{
Argument.AssertNotNullOrEmpty(containerId, nameof(containerId));

ClientResult result = GetContainer(containerId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
ClientResult result = GetContainer(containerId, cancellationToken.ToRequestOptions());
return ClientResult.FromValue((ContainerResource)result, result.GetRawResponse());
}

public virtual async Task<ClientResult<ContainerResource>> GetContainerAsync(string containerId, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(containerId, nameof(containerId));

ClientResult result = await GetContainerAsync(containerId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false);
ClientResult result = await GetContainerAsync(containerId, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
return ClientResult.FromValue((ContainerResource)result, result.GetRawResponse());
}

Expand All @@ -127,15 +127,15 @@ public virtual ClientResult<DeleteContainerResponse> DeleteContainer(string cont
{
Argument.AssertNotNullOrEmpty(containerId, nameof(containerId));

ClientResult result = DeleteContainer(containerId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
ClientResult result = DeleteContainer(containerId, cancellationToken.ToRequestOptions());
return ClientResult.FromValue((DeleteContainerResponse)result, result.GetRawResponse());
}

public virtual async Task<ClientResult<DeleteContainerResponse>> DeleteContainerAsync(string containerId, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(containerId, nameof(containerId));

ClientResult result = await DeleteContainerAsync(containerId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false);
ClientResult result = await DeleteContainerAsync(containerId, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
return ClientResult.FromValue((DeleteContainerResponse)result, result.GetRawResponse());
}

Expand Down Expand Up @@ -193,7 +193,7 @@ public virtual CollectionResult<ContainerFileResource> GetContainerFiles(string
options?.PageSizeLimit,
options?.Order?.ToString(),
options?.AfterId,
cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
cancellationToken.ToRequestOptions());
}

public virtual AsyncCollectionResult<ContainerFileResource> GetContainerFilesAsync(string containerId, ContainerFileCollectionOptions options = default, CancellationToken cancellationToken = default)
Expand All @@ -206,7 +206,7 @@ public virtual AsyncCollectionResult<ContainerFileResource> GetContainerFilesAsy
options?.PageSizeLimit,
options?.Order?.ToString(),
options?.AfterId,
cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
cancellationToken.ToRequestOptions());
}

public virtual ClientResult GetContainerFile(string containerId, string fileId, RequestOptions options)
Expand All @@ -232,7 +232,7 @@ public virtual ClientResult<ContainerFileResource> GetContainerFile(string conta
Argument.AssertNotNullOrEmpty(containerId, nameof(containerId));
Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));

ClientResult result = GetContainerFile(containerId, fileId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
ClientResult result = GetContainerFile(containerId, fileId, cancellationToken.ToRequestOptions());
return ClientResult.FromValue((ContainerFileResource)result, result.GetRawResponse());
}

Expand All @@ -241,7 +241,7 @@ public virtual async Task<ClientResult<ContainerFileResource>> GetContainerFileA
Argument.AssertNotNullOrEmpty(containerId, nameof(containerId));
Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));

ClientResult result = await GetContainerFileAsync(containerId, fileId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false);
ClientResult result = await GetContainerFileAsync(containerId, fileId, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
return ClientResult.FromValue((ContainerFileResource)result, result.GetRawResponse());
}

Expand All @@ -268,7 +268,7 @@ public virtual ClientResult<DeleteContainerFileResponse> DeleteContainerFile(str
Argument.AssertNotNullOrEmpty(containerId, nameof(containerId));
Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));

ClientResult result = DeleteContainerFile(containerId, fileId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
ClientResult result = DeleteContainerFile(containerId, fileId, cancellationToken.ToRequestOptions());
return ClientResult.FromValue((DeleteContainerFileResponse)result, result.GetRawResponse());
}

Expand All @@ -277,7 +277,7 @@ public virtual async Task<ClientResult<DeleteContainerFileResponse>> DeleteConta
Argument.AssertNotNullOrEmpty(containerId, nameof(containerId));
Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));

ClientResult result = await DeleteContainerFileAsync(containerId, fileId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false);
ClientResult result = await DeleteContainerFileAsync(containerId, fileId, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
return ClientResult.FromValue((DeleteContainerFileResponse)result, result.GetRawResponse());
}

Expand All @@ -304,7 +304,7 @@ public virtual ClientResult<BinaryData> DownloadContainerFile(string containerId
Argument.AssertNotNullOrEmpty(containerId, nameof(containerId));
Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));

ClientResult result = DownloadContainerFile(containerId, fileId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
ClientResult result = DownloadContainerFile(containerId, fileId, cancellationToken.ToRequestOptions());
return ClientResult.FromValue(result.GetRawResponse().Content, result.GetRawResponse());
}

Expand All @@ -313,7 +313,7 @@ public virtual async Task<ClientResult<BinaryData>> DownloadContainerFileAsync(s
Argument.AssertNotNullOrEmpty(containerId, nameof(containerId));
Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));

ClientResult result = await DownloadContainerFileAsync(containerId, fileId, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false);
ClientResult result = await DownloadContainerFileAsync(containerId, fileId, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
return ClientResult.FromValue(result.GetRawResponse().Content, result.GetRawResponse());
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/Generated/Internal/CancellationTokenExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// <auto-generated/>

#nullable disable

using System.ClientModel.Primitives;
using System.Threading;

namespace OpenAI
{
internal static partial class CancellationTokenExtensions
{
public static RequestOptions ToRequestOptions(this CancellationToken cancellationToken) => cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null;
}
}
4 changes: 2 additions & 2 deletions src/Generated/InternalAssistantMessageClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public virtual CollectionResult<ThreadMessage> GetMessages(string threadId, Mess
options?.Order?.ToString(),
options?.AfterId,
options?.BeforeId,
cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
cancellationToken.ToRequestOptions());
}

public virtual AsyncCollectionResult<ThreadMessage> GetMessagesAsync(string threadId, MessageCollectionOptions options = default, CancellationToken cancellationToken = default)
Expand All @@ -79,7 +79,7 @@ public virtual AsyncCollectionResult<ThreadMessage> GetMessagesAsync(string thre
options?.Order?.ToString(),
options?.AfterId,
options?.BeforeId,
cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
cancellationToken.ToRequestOptions());
}
}
}
Loading
Loading