Skip to content

Commit 4376162

Browse files
authored
Add ResponseItem constructors (#625)
All the classes derived from `ResponseItem` now have public constructors, and these constructors are generated. A side effect of making these classes behave as both, inputs and outputs, was that their required properties got setters. Setters make sense when the values of these properties can be updated, but in this particular case they should only be settable at construction time. This is a limitation in the code generator being tracked by the following issue: 🔗 microsoft/typespec#5175 (comment)
1 parent 652ff02 commit 4376162

File tree

100 files changed

+541
-636
lines changed

Some content is hidden

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

100 files changed

+541
-636
lines changed

api/OpenAI.net8.0.cs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4594,10 +4594,21 @@ public enum ComputerCallActionMouseButton {
45944594
Forward = 4
45954595
}
45964596
[Experimental("OPENAICUA001")]
4597+
public class ComputerCallOutput : IJsonModel<ComputerCallOutput>, IPersistableModel<ComputerCallOutput> {
4598+
public static ComputerCallOutput CreateScreenshotOutput(BinaryData screenshotImageBytes, string screenshotImageBytesMediaType);
4599+
public static ComputerCallOutput CreateScreenshotOutput(string screenshotImageFileId);
4600+
public static ComputerCallOutput CreateScreenshotOutput(Uri screenshotImageUri);
4601+
protected virtual ComputerCallOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
4602+
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
4603+
protected virtual ComputerCallOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
4604+
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
4605+
}
4606+
[Experimental("OPENAICUA001")]
45974607
public class ComputerCallOutputResponseItem : ResponseItem, IJsonModel<ComputerCallOutputResponseItem>, IPersistableModel<ComputerCallOutputResponseItem> {
4608+
public ComputerCallOutputResponseItem(string callId, ComputerCallOutput output);
45984609
public IList<ComputerCallSafetyCheck> AcknowledgedSafetyChecks { get; }
4599-
public string CallId { get; }
4600-
public ComputerOutput Output { get; }
4610+
public string CallId { get; set; }
4611+
public ComputerCallOutput Output { get; set; }
46014612
public ComputerCallOutputStatus? Status { get; }
46024613
protected override ResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
46034614
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
@@ -4613,8 +4624,8 @@ public enum ComputerCallOutputStatus {
46134624
[Experimental("OPENAICUA001")]
46144625
public class ComputerCallResponseItem : ResponseItem, IJsonModel<ComputerCallResponseItem>, IPersistableModel<ComputerCallResponseItem> {
46154626
public ComputerCallResponseItem(string callId, ComputerCallAction action, IEnumerable<ComputerCallSafetyCheck> pendingSafetyChecks);
4616-
public ComputerCallAction Action { get; }
4617-
public string CallId { get; }
4627+
public ComputerCallAction Action { get; set; }
4628+
public string CallId { get; set; }
46184629
public IList<ComputerCallSafetyCheck> PendingSafetyChecks { get; }
46194630
public ComputerCallStatus? Status { get; }
46204631
protected override ResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
@@ -4640,16 +4651,6 @@ public enum ComputerCallStatus {
46404651
Incomplete = 2
46414652
}
46424653
[Experimental("OPENAICUA001")]
4643-
public class ComputerOutput : IJsonModel<ComputerOutput>, IPersistableModel<ComputerOutput> {
4644-
public static ComputerOutput CreateScreenshotOutput(BinaryData screenshotImageBytes, string screenshotImageBytesMediaType);
4645-
public static ComputerOutput CreateScreenshotOutput(string screenshotImageFileId);
4646-
public static ComputerOutput CreateScreenshotOutput(Uri screenshotImageUri);
4647-
protected virtual ComputerOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
4648-
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
4649-
protected virtual ComputerOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
4650-
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
4651-
}
4652-
[Experimental("OPENAICUA001")]
46534654
public readonly partial struct ComputerToolEnvironment : IEquatable<ComputerToolEnvironment> {
46544655
public ComputerToolEnvironment(string value);
46554656
public static ComputerToolEnvironment Browser { get; }
@@ -4670,8 +4671,9 @@ public class ComputerOutput : IJsonModel<ComputerOutput>, IPersistableModel<Comp
46704671
}
46714672
[Experimental("OPENAI001")]
46724673
public class FileSearchCallResponseItem : ResponseItem, IJsonModel<FileSearchCallResponseItem>, IPersistableModel<FileSearchCallResponseItem> {
4674+
public FileSearchCallResponseItem(IEnumerable<string> queries);
46734675
public IList<string> Queries { get; }
4674-
public IList<FileSearchCallResult> Results { get; }
4676+
public IList<FileSearchCallResult> Results { get; set; }
46754677
public FileSearchCallStatus? Status { get; }
46764678
protected override ResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
46774679
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
@@ -4680,7 +4682,7 @@ public class FileSearchCallResponseItem : ResponseItem, IJsonModel<FileSearchCal
46804682
}
46814683
[Experimental("OPENAI001")]
46824684
public class FileSearchCallResult : IJsonModel<FileSearchCallResult>, IPersistableModel<FileSearchCallResult> {
4683-
public IReadOnlyDictionary<string, BinaryData> Attributes { get; }
4685+
public IDictionary<string, BinaryData> Attributes { get; }
46844686
public string FileId { get; set; }
46854687
public string Filename { get; set; }
46864688
public float? Score { get; set; }
@@ -4725,7 +4727,8 @@ public class FileSearchToolRankingOptions : IJsonModel<FileSearchToolRankingOpti
47254727
}
47264728
[Experimental("OPENAI001")]
47274729
public class FunctionCallOutputResponseItem : ResponseItem, IJsonModel<FunctionCallOutputResponseItem>, IPersistableModel<FunctionCallOutputResponseItem> {
4728-
public string CallId { get; }
4730+
public FunctionCallOutputResponseItem(string callId, string functionOutput);
4731+
public string CallId { get; set; }
47294732
public string FunctionOutput { get; set; }
47304733
public FunctionCallOutputStatus? Status { get; }
47314734
protected override ResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
@@ -4741,7 +4744,8 @@ public enum FunctionCallOutputStatus {
47414744
}
47424745
[Experimental("OPENAI001")]
47434746
public class FunctionCallResponseItem : ResponseItem, IJsonModel<FunctionCallResponseItem>, IPersistableModel<FunctionCallResponseItem> {
4744-
public string CallId { get; }
4747+
public FunctionCallResponseItem(string callId, string functionName, BinaryData functionArguments);
4748+
public string CallId { get; set; }
47454749
public BinaryData FunctionArguments { get; set; }
47464750
public string FunctionName { get; set; }
47474751
public FunctionCallStatus? Status { get; }
@@ -4867,9 +4871,9 @@ public static class OpenAIResponsesModelFactory {
48674871
public class ReasoningResponseItem : ResponseItem, IJsonModel<ReasoningResponseItem>, IPersistableModel<ReasoningResponseItem> {
48684872
public ReasoningResponseItem(IEnumerable<ReasoningSummaryPart> summaryParts);
48694873
public ReasoningResponseItem(string summaryText);
4870-
public string EncryptedContent { get; }
4874+
public string EncryptedContent { get; set; }
48714875
public ReasoningStatus? Status { get; }
4872-
public IReadOnlyList<ReasoningSummaryPart> SummaryParts { get; }
4876+
public IList<ReasoningSummaryPart> SummaryParts { get; }
48734877
public string GetSummaryText();
48744878
protected override ResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
48754879
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
@@ -4884,7 +4888,7 @@ public enum ReasoningStatus {
48844888
}
48854889
[Experimental("OPENAI001")]
48864890
public class ReasoningSummaryPart : IJsonModel<ReasoningSummaryPart>, IPersistableModel<ReasoningSummaryPart> {
4887-
public static ReasoningSummaryPart CreateTextPart(string text);
4891+
public static ReasoningSummaryTextPart CreateTextPart(string text);
48884892
protected virtual ReasoningSummaryPart JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
48894893
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
48904894
protected virtual ReasoningSummaryPart PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
@@ -5072,14 +5076,10 @@ public class ResponseItem : IJsonModel<ResponseItem>, IPersistableModel<Response
50725076
[Experimental("OPENAICUA001")]
50735077
public static ComputerCallResponseItem CreateComputerCallItem(string callId, ComputerCallAction action, IEnumerable<ComputerCallSafetyCheck> pendingSafetyChecks);
50745078
[Experimental("OPENAICUA001")]
5075-
public static ComputerCallOutputResponseItem CreateComputerCallOutputItem(string callId, IList<ComputerCallSafetyCheck> acknowledgedSafetyChecks, BinaryData screenshotImageBytes, string screenshotImageBytesMediaType);
5076-
[Experimental("OPENAICUA001")]
5077-
public static ComputerCallOutputResponseItem CreateComputerCallOutputItem(string callId, IList<ComputerCallSafetyCheck> acknowledgedSafetyChecks, string screenshotImageFileId);
5078-
[Experimental("OPENAICUA001")]
5079-
public static ComputerCallOutputResponseItem CreateComputerCallOutputItem(string callId, IList<ComputerCallSafetyCheck> acknowledgedSafetyChecks, Uri screenshotImageUri);
5079+
public static ComputerCallOutputResponseItem CreateComputerCallOutputItem(string callId, ComputerCallOutput output);
50805080
public static MessageResponseItem CreateDeveloperMessageItem(IEnumerable<ResponseContentPart> contentParts);
50815081
public static MessageResponseItem CreateDeveloperMessageItem(string inputTextContent);
5082-
public static FileSearchCallResponseItem CreateFileSearchCallItem(IEnumerable<string> queries, IEnumerable<FileSearchCallResult> results);
5082+
public static FileSearchCallResponseItem CreateFileSearchCallItem(IEnumerable<string> queries);
50835083
public static FunctionCallResponseItem CreateFunctionCallItem(string callId, string functionName, BinaryData functionArguments);
50845084
public static FunctionCallOutputResponseItem CreateFunctionCallOutputItem(string callId, string functionOutput);
50855085
public static ReasoningResponseItem CreateReasoningItem(IEnumerable<ReasoningSummaryPart> summaryParts);
@@ -5551,6 +5551,7 @@ public class StreamingResponseWebSearchCallSearchingUpdate : StreamingResponseUp
55515551
}
55525552
[Experimental("OPENAI001")]
55535553
public class WebSearchCallResponseItem : ResponseItem, IJsonModel<WebSearchCallResponseItem>, IPersistableModel<WebSearchCallResponseItem> {
5554+
public WebSearchCallResponseItem();
55545555
public WebSearchCallStatus? Status { get; }
55555556
protected override ResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
55565557
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);

0 commit comments

Comments
 (0)