Skip to content

Commit 0ca4c06

Browse files
authored
Prepare 2.2.0-beta.3 release (Part 1) (#368)
1 parent 3d7d89d commit 0ca4c06

File tree

1,257 files changed

+32091
-7012
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,257 files changed

+32091
-7012
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Release History
22

3+
## 2.2.0-beta.3 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
### Bugs Fixed
10+
11+
### Other Changes
12+
313
## 2.2.0-beta.2 (2025-02-18)
414

515
### Bugs fixed

api/OpenAI.net8.0.cs

Lines changed: 672 additions & 10 deletions
Large diffs are not rendered by default.

api/OpenAI.netstandard2.0.cs

Lines changed: 666 additions & 10 deletions
Large diffs are not rendered by default.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using NUnit.Framework;
2+
using OpenAI.Responses;
3+
using System;
4+
using System.ClientModel;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Threading.Tasks;
9+
10+
namespace OpenAI.Examples;
11+
12+
#pragma warning disable OPENAICUA001
13+
14+
public partial class ResponsesExamples
15+
{
16+
[Test]
17+
public async Task Example01_CuaFlow()
18+
{
19+
OpenAIResponseClient client = new(
20+
model: "computer-use-preview",
21+
credential: new ApiKeyCredential(Environment.GetEnvironmentVariable("OPENAI_API_KEY")));
22+
23+
OpenAIResponse response = await client.CreateResponseAsync(
24+
[ResponseItem.CreateUserMessageItem("Click on the OK button")],
25+
new ResponseCreationOptions()
26+
{
27+
Tools = { ResponseTool.CreateComputerTool(1024, 768, ComputerToolEnvironment.Windows) },
28+
});
29+
30+
if (response.OutputItems.FirstOrDefault() is ComputerCallResponseItem computerCall)
31+
{
32+
if (computerCall.Action.Kind == ComputerCallActionKind.Screenshot)
33+
{
34+
Uri screenshotLink = new("https://uxmovement.com/wp-content/uploads/2011/05/left-to-right-mapping.png");
35+
36+
response = await client.CreateResponseAsync(
37+
[ResponseItem.CreateComputerCallOutputItem(computerCall.Id, [], screenshotLink)]);
38+
}
39+
else if (computerCall.Action.Kind == ComputerCallActionKind.Click)
40+
{
41+
Console.WriteLine($"Instruction from model: click");
42+
}
43+
}
44+
}
45+
}
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
namespace OpenAI.Administration;
22

3-
[CodeGenModel("AuditLogActorServiceAccount")] internal partial class InternalAuditLogActorServiceAccount { }
4-
[CodeGenModel("AuditLogActorUser")] internal partial class InternalAuditLogActorUser { }
5-
[CodeGenModel("AuditLogActorApiKey")] internal partial class InternalAuditLogActorApiKey { }
6-
[CodeGenModel("AuditLogActorSession")] internal partial class InternalAuditLogActorSession { }
7-
[CodeGenModel("AuditLogActor")] internal partial class InternalAuditLogActor { }
8-
[CodeGenModel("AuditLog")] internal partial class InternalAuditLog { }
9-
[CodeGenModel("ListAuditLogsResponse")] internal partial class InternalListAuditLogsResponse { }
10-
[CodeGenModel("Invite")] internal partial class InternalInvite { }
11-
[CodeGenModel("InviteListResponse")] internal partial class InternalInviteListResponse { }
12-
[CodeGenModel("InviteRequest")] internal partial class InternalInviteRequest { }
13-
[CodeGenModel("InviteDeleteResponse")] internal partial class InternalInviteDeleteResponse { }
14-
[CodeGenModel("User")] internal partial class InternalUser { }
15-
[CodeGenModel("UserListResponse")] internal partial class InternalUserListResponse { }
16-
[CodeGenModel("UserRoleUpdateRequest")] internal partial class InternalUserRoleUpdateRequest { }
17-
[CodeGenModel("UserDeleteResponse")] internal partial class InternalUserDeleteResponse { }
18-
[CodeGenModel("Project")] internal partial class InternalProject { }
19-
[CodeGenModel("ProjectListResponse")] internal partial class InternalProjectListResponse { }
20-
[CodeGenModel("ProjectCreateRequest")] internal partial class InternalProjectCreateRequest { }
21-
[CodeGenModel("ProjectUpdateRequest")] internal partial class InternalProjectUpdateRequest { }
22-
[CodeGenModel("DefaultProjectErrorResponse")] internal partial class InternalDefaultProjectErrorResponse { }
23-
[CodeGenModel("ProjectUser")] internal partial class InternalProjectUser { }
24-
[CodeGenModel("ProjectUserListResponse")] internal partial class InternalProjectUserListResponse { }
25-
[CodeGenModel("ProjectUserCreateRequest")] internal partial class InternalProjectUserCreateRequest { }
26-
[CodeGenModel("ProjectUserUpdateRequest")] internal partial class InternalProjectUserUpdateRequest { }
27-
[CodeGenModel("ProjectUserDeleteResponse")] internal partial class InternalProjectUserDeleteResponse { }
28-
[CodeGenModel("ProjectServiceAccount")] internal partial class InternalProjectServiceAccount { }
29-
[CodeGenModel("ProjectServiceAccountListResponse")] internal partial class InternalProjectServiceAccountListResponse { }
30-
[CodeGenModel("ProjectServiceAccountCreateRequest")] internal partial class InternalProjectServiceAccountCreateRequest { }
31-
[CodeGenModel("ProjectServiceAccountCreateResponse")] internal partial class InternalProjectServiceAccountCreateResponse { }
32-
[CodeGenModel("ProjectServiceAccountApiKey")] internal partial class InternalProjectServiceAccountApiKey { }
33-
[CodeGenModel("ProjectServiceAccountDeleteResponse")] internal partial class InternalProjectServiceAccountDeleteResponse { }
34-
[CodeGenModel("ProjectApiKey")] internal partial class InternalProjectApiKey { }
35-
[CodeGenModel("ProjectApiKeyListResponse")] internal partial class InternalProjectApiKeyListResponse { }
36-
[CodeGenModel("ProjectApiKeyDeleteResponse")] internal partial class InternalProjectApiKeyDeleteResponse { }
3+
[CodeGenType("AuditLogActorServiceAccount")] internal partial class InternalAuditLogActorServiceAccount { }
4+
[CodeGenType("AuditLogActorUser")] internal partial class InternalAuditLogActorUser { }
5+
[CodeGenType("AuditLogActorApiKey")] internal partial class InternalAuditLogActorApiKey { }
6+
[CodeGenType("AuditLogActorSession")] internal partial class InternalAuditLogActorSession { }
7+
[CodeGenType("AuditLogActor")] internal partial class InternalAuditLogActor { }
8+
[CodeGenType("AuditLog")] internal partial class InternalAuditLog { }
9+
[CodeGenType("ListAuditLogsResponse")] internal partial class InternalListAuditLogsResponse { }
10+
[CodeGenType("Invite")] internal partial class InternalInvite { }
11+
[CodeGenType("InviteListResponse")] internal partial class InternalInviteListResponse { }
12+
[CodeGenType("InviteRequest")] internal partial class InternalInviteRequest { }
13+
[CodeGenType("InviteDeleteResponse")] internal partial class InternalInviteDeleteResponse { }
14+
[CodeGenType("User")] internal partial class InternalUser { }
15+
[CodeGenType("UserListResponse")] internal partial class InternalUserListResponse { }
16+
[CodeGenType("UserRoleUpdateRequest")] internal partial class InternalUserRoleUpdateRequest { }
17+
[CodeGenType("UserDeleteResponse")] internal partial class InternalUserDeleteResponse { }
18+
[CodeGenType("Project")] internal partial class InternalProject { }
19+
[CodeGenType("ProjectListResponse")] internal partial class InternalProjectListResponse { }
20+
[CodeGenType("ProjectCreateRequest")] internal partial class InternalProjectCreateRequest { }
21+
[CodeGenType("ProjectUpdateRequest")] internal partial class InternalProjectUpdateRequest { }
22+
[CodeGenType("DefaultProjectErrorResponse")] internal partial class InternalDefaultProjectErrorResponse { }
23+
[CodeGenType("ProjectUser")] internal partial class InternalProjectUser { }
24+
[CodeGenType("ProjectUserListResponse")] internal partial class InternalProjectUserListResponse { }
25+
[CodeGenType("ProjectUserCreateRequest")] internal partial class InternalProjectUserCreateRequest { }
26+
[CodeGenType("ProjectUserUpdateRequest")] internal partial class InternalProjectUserUpdateRequest { }
27+
[CodeGenType("ProjectUserDeleteResponse")] internal partial class InternalProjectUserDeleteResponse { }
28+
[CodeGenType("ProjectServiceAccount")] internal partial class InternalProjectServiceAccount { }
29+
[CodeGenType("ProjectServiceAccountListResponse")] internal partial class InternalProjectServiceAccountListResponse { }
30+
[CodeGenType("ProjectServiceAccountCreateRequest")] internal partial class InternalProjectServiceAccountCreateRequest { }
31+
[CodeGenType("ProjectServiceAccountCreateResponse")] internal partial class InternalProjectServiceAccountCreateResponse { }
32+
[CodeGenType("ProjectServiceAccountApiKey")] internal partial class InternalProjectServiceAccountApiKey { }
33+
[CodeGenType("ProjectServiceAccountDeleteResponse")] internal partial class InternalProjectServiceAccountDeleteResponse { }
34+
[CodeGenType("ProjectApiKey")] internal partial class InternalProjectApiKey { }
35+
[CodeGenType("ProjectApiKeyListResponse")] internal partial class InternalProjectApiKeyListResponse { }
36+
[CodeGenType("ProjectApiKeyDeleteResponse")] internal partial class InternalProjectApiKeyDeleteResponse { }

src/Custom/Assistants/Assistant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace OpenAI.Assistants;
44

55
[Experimental("OPENAI001")]
6-
[CodeGenModel("AssistantObject")]
6+
[CodeGenType("AssistantObject")]
77
public partial class Assistant
88
{
99
// CUSTOM: Made internal.

src/Custom/Assistants/AssistantClient.cs

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace OpenAI.Assistants;
1212

1313
/// <summary> The service client for OpenAI assistants operations. </summary>
1414
[Experimental("OPENAI001")]
15-
[CodeGenClient("Assistants")]
16-
[CodeGenSuppress("AssistantClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))]
15+
[CodeGenType("Assistants")]
16+
[CodeGenSuppress("AssistantClient", typeof(ClientPipeline), typeof(Uri))]
1717
[CodeGenSuppress("CreateAssistantAsync", typeof(AssistantCreationOptions), typeof(CancellationToken))]
1818
[CodeGenSuppress("CreateAssistant", typeof(AssistantCreationOptions), typeof(CancellationToken))]
1919
[CodeGenSuppress("GetAssistantAsync", typeof(string))]
@@ -22,8 +22,8 @@ namespace OpenAI.Assistants;
2222
[CodeGenSuppress("ModifyAssistant", typeof(string), typeof(AssistantModificationOptions))]
2323
[CodeGenSuppress("DeleteAssistantAsync", typeof(string))]
2424
[CodeGenSuppress("DeleteAssistant", typeof(string))]
25-
[CodeGenSuppress("ListAssistantsAsync", typeof(int?), typeof(AssistantCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
26-
[CodeGenSuppress("ListAssistants", typeof(int?), typeof(AssistantCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
25+
[CodeGenSuppress("ListAssistantsAsync", typeof(int?), typeof(OpenAI.VectorStores.VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
26+
[CodeGenSuppress("ListAssistants", typeof(int?), typeof(OpenAI.VectorStores.VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
2727
public partial class AssistantClient
2828
{
2929
private readonly InternalAssistantMessageClient _messageSubClient;
@@ -725,11 +725,10 @@ public virtual AsyncCollectionResult<StreamingUpdate> CreateRunStreamingAsync(
725725
options.AssistantId = assistantId;
726726
options.Stream = true;
727727

728-
async Task<ClientResult> sendRequestAsync() =>
729-
await CreateRunAsync(threadId, options, cancellationToken.ToRequestOptions(streaming: true))
730-
.ConfigureAwait(false);
731-
732-
return new AsyncStreamingUpdateCollection(sendRequestAsync, cancellationToken);
728+
return new AsyncSseUpdateCollection<StreamingUpdate>(
729+
async () => await CreateRunAsync(threadId, options, cancellationToken.ToRequestOptions(streaming: true)).ConfigureAwait(false),
730+
StreamingUpdate.FromSseItem,
731+
cancellationToken);
733732
}
734733

735734
/// <summary>
@@ -753,8 +752,10 @@ public virtual CollectionResult<StreamingUpdate> CreateRunStreaming(
753752
options.AssistantId = assistantId;
754753
options.Stream = true;
755754

756-
ClientResult sendRequest() => CreateRun(threadId, options, cancellationToken.ToRequestOptions(streaming: true));
757-
return new StreamingUpdateCollection(sendRequest, cancellationToken);
755+
return new SseUpdateCollection<StreamingUpdate>(
756+
() => CreateRun(threadId, options, cancellationToken.ToRequestOptions(streaming: true)),
757+
StreamingUpdate.FromSseItem,
758+
cancellationToken);
758759
}
759760

760761
/// <summary>
@@ -818,11 +819,10 @@ public virtual AsyncCollectionResult<StreamingUpdate> CreateThreadAndRunStreamin
818819
runOptions.Stream = true;
819820
BinaryContent protocolContent = CreateThreadAndRunProtocolContent(assistantId, threadOptions, runOptions);
820821

821-
async Task<ClientResult> sendRequestAsync() =>
822-
await CreateThreadAndRunAsync(protocolContent, cancellationToken.ToRequestOptions(streaming: true))
823-
.ConfigureAwait(false);
824-
825-
return new AsyncStreamingUpdateCollection(sendRequestAsync, cancellationToken);
822+
return new AsyncSseUpdateCollection<StreamingUpdate>(
823+
async () => await CreateThreadAndRunAsync(protocolContent, cancellationToken.ToRequestOptions(streaming: true)).ConfigureAwait(false),
824+
StreamingUpdate.FromSseItem,
825+
cancellationToken);
826826
}
827827

828828
/// <summary>
@@ -844,8 +844,10 @@ public virtual CollectionResult<StreamingUpdate> CreateThreadAndRunStreaming(
844844
runOptions.Stream = true;
845845
BinaryContent protocolContent = CreateThreadAndRunProtocolContent(assistantId, threadOptions, runOptions);
846846

847-
ClientResult sendRequest() => CreateThreadAndRun(protocolContent, cancellationToken.ToRequestOptions(streaming: true));
848-
return new StreamingUpdateCollection(sendRequest, cancellationToken);
847+
return new SseUpdateCollection<StreamingUpdate>(
848+
() => CreateThreadAndRun(protocolContent, cancellationToken.ToRequestOptions(streaming: true)),
849+
StreamingUpdate.FromSseItem,
850+
cancellationToken);
849851
}
850852

851853
/// <summary>
@@ -1043,11 +1045,10 @@ public virtual AsyncCollectionResult<StreamingUpdate> SubmitToolOutputsToRunStre
10431045

10441046
BinaryContent content = new InternalSubmitToolOutputsRunRequest(toolOutputs.ToList(), stream: true, null);
10451047

1046-
async Task<ClientResult> sendRequestAsync() =>
1047-
await SubmitToolOutputsToRunAsync(threadId, runId, content, cancellationToken.ToRequestOptions(streaming: true))
1048-
.ConfigureAwait(false);
1049-
1050-
return new AsyncStreamingUpdateCollection(sendRequestAsync, cancellationToken);
1048+
return new AsyncSseUpdateCollection<StreamingUpdate>(
1049+
async () => await SubmitToolOutputsToRunAsync(threadId, runId, content, cancellationToken.ToRequestOptions(streaming: true)).ConfigureAwait(false),
1050+
StreamingUpdate.FromSseItem,
1051+
cancellationToken);
10511052
}
10521053

10531054
/// <summary>
@@ -1070,8 +1071,10 @@ public virtual CollectionResult<StreamingUpdate> SubmitToolOutputsToRunStreaming
10701071

10711072
BinaryContent content = new InternalSubmitToolOutputsRunRequest(toolOutputs.ToList(), stream: true, null);
10721073

1073-
ClientResult sendRequest() => SubmitToolOutputsToRun(threadId, runId, content, cancellationToken.ToRequestOptions(streaming: true));
1074-
return new StreamingUpdateCollection(sendRequest, cancellationToken);
1074+
return new SseUpdateCollection<StreamingUpdate>(
1075+
() => SubmitToolOutputsToRun(threadId, runId, content, cancellationToken.ToRequestOptions(streaming: true)),
1076+
StreamingUpdate.FromSseItem,
1077+
cancellationToken);
10751078
}
10761079

10771080
/// <summary>
Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
1-
using System.Diagnostics.CodeAnalysis;
1+
using System;
2+
using System.ComponentModel;
3+
using System.Diagnostics.CodeAnalysis;
24

35
namespace OpenAI.Assistants;
46

5-
// CUSTOM: Renamed.
67
[Experimental("OPENAI001")]
7-
[CodeGenModel("ListAssistantsRequestOrder")]
8-
public readonly partial struct AssistantCollectionOrder
8+
public readonly partial struct AssistantCollectionOrder: IEquatable<AssistantCollectionOrder>
99
{
10-
// CUSTOM: Renamed.
11-
[CodeGenMember("Asc")]
12-
public static AssistantCollectionOrder Ascending { get; } = new AssistantCollectionOrder(AscValue);
10+
public static AssistantCollectionOrder Ascending { get; } = new AssistantCollectionOrder("asc");
1311

14-
// CUSTOM: Renamed.
15-
[CodeGenMember("Desc")]
16-
public static AssistantCollectionOrder Descending { get; } = new AssistantCollectionOrder(DescValue);
12+
public static AssistantCollectionOrder Descending { get; } = new AssistantCollectionOrder("desc");
13+
14+
private readonly string _value;
15+
private const string AscValue = "asc";
16+
private const string DescValue = "desc";
17+
18+
public AssistantCollectionOrder(string value)
19+
{
20+
Argument.AssertNotNull(value, nameof(value));
21+
22+
_value = value;
23+
}
24+
25+
public static bool operator ==(AssistantCollectionOrder left, AssistantCollectionOrder right) => left.Equals(right);
26+
27+
public static bool operator !=(AssistantCollectionOrder left, AssistantCollectionOrder right) => !left.Equals(right);
28+
29+
public static implicit operator AssistantCollectionOrder(string value) => new AssistantCollectionOrder(value);
30+
31+
[EditorBrowsable(EditorBrowsableState.Never)]
32+
public override bool Equals(object obj) => obj is AssistantCollectionOrder other && Equals(other);
33+
34+
public bool Equals(AssistantCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
35+
36+
[EditorBrowsable(EditorBrowsableState.Never)]
37+
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
38+
39+
public override string ToString() => _value;
1740
}

src/Custom/Assistants/AssistantCreationOptions.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using OpenAI.Chat;
12
using System.Collections.Generic;
23
using System.Diagnostics.CodeAnalysis;
34

@@ -7,7 +8,7 @@ namespace OpenAI.Assistants;
78
/// Represents additional options available when creating a new <see cref="Assistant"/>.
89
/// </summary>
910
[Experimental("OPENAI001")]
10-
[CodeGenModel("CreateAssistantRequest")]
11+
[CodeGenType("CreateAssistantRequest")]
1112
[CodeGenSuppress(nameof(AssistantCreationOptions), typeof(string))]
1213
public partial class AssistantCreationOptions
1314
{
@@ -39,11 +40,9 @@ public partial class AssistantCreationOptions
3940
[CodeGenMember("TopP")]
4041
public float? NucleusSamplingFactor { get; set; }
4142

42-
internal AssistantCreationOptions(InternalCreateAssistantRequestModel model)
43-
: this()
44-
{
45-
Model = model.ToString();
46-
}
43+
// CUSTOM: Made internal.
44+
[CodeGenMember("ReasoningEffort")]
45+
internal ChatReasoningEffortLevel? ReasoningEffortLevel { get; set; }
4746

4847
/// <summary>
4948
/// Creates a new instance of <see cref="AssistantCreationOptions"/>.

src/Custom/Assistants/AssistantDeletionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace OpenAI.Assistants;
44

55
[Experimental("OPENAI001")]
6-
[CodeGenModel("DeleteAssistantResponse")]
6+
[CodeGenType("DeleteAssistantResponse")]
77
public partial class AssistantDeletionResult
88
{
99
// CUSTOM: Renamed.

0 commit comments

Comments
 (0)