Skip to content

Commit a8c6bc9

Browse files
committed
Add support for the latest Response properties
1 parent 3be7414 commit a8c6bc9

17 files changed

+9636
-9329
lines changed

api/OpenAI.net8.0.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,8 @@ public class ChatCompletionOptions : IJsonModel<ChatCompletionOptions>, IPersist
17231723
[Experimental("OPENAI001")]
17241724
public ChatResponseModalities ResponseModalities { get; set; }
17251725
[Experimental("OPENAI001")]
1726+
public string SafetyIdentifier { get; set; }
1727+
[Experimental("OPENAI001")]
17261728
public long? Seed { get; set; }
17271729
[Experimental("OPENAI001")]
17281730
public ChatServiceTier? ServiceTier { get; set; }
@@ -5598,6 +5600,7 @@ public class OpenAIResponse : IJsonModel<OpenAIResponse>, IPersistableModel<Open
55985600
public ResponseIncompleteStatusDetails IncompleteStatusDetails { get; }
55995601
public string Instructions { get; }
56005602
public int? MaxOutputTokenCount { get; }
5603+
public int? MaxToolCallCount { get; }
56015604
public IDictionary<string, string> Metadata { get; }
56025605
public string Model { get; }
56035606
public IList<ResponseItem> OutputItems { get; }
@@ -5670,7 +5673,7 @@ public class OpenAIResponseClient {
56705673
[Experimental("OPENAI001")]
56715674
public static class OpenAIResponsesModelFactory {
56725675
public static MessageResponseItem MessageResponseItem(string id = null, MessageRole role = MessageRole.Assistant, MessageStatus? status = null);
5673-
public static OpenAIResponse OpenAIResponse(string id = null, DateTimeOffset createdAt = default, ResponseStatus? status = null, ResponseError error = null, ResponseTokenUsage usage = null, string endUserId = null, ResponseReasoningOptions reasoningOptions = null, int? maxOutputTokenCount = null, ResponseTextOptions textOptions = null, ResponseTruncationMode? truncationMode = null, ResponseIncompleteStatusDetails incompleteStatusDetails = null, IEnumerable<ResponseItem> outputItems = null, bool parallelToolCallsEnabled = false, ResponseToolChoice toolChoice = null, string model = null, IDictionary<string, string> metadata = null, float? temperature = null, float? topP = null, ResponseServiceTier? serviceTier = null, string previousResponseId = null, bool? backgroundModeEnabled = null, string instructions = null, IEnumerable<ResponseTool> tools = null);
5676+
public static OpenAIResponse OpenAIResponse(string id = null, DateTimeOffset createdAt = default, ResponseStatus? status = null, ResponseError error = null, ResponseTokenUsage usage = null, string endUserId = null, ResponseReasoningOptions reasoningOptions = null, int? maxOutputTokenCount = null, int? maxToolCallCount = null, ResponseTextOptions textOptions = null, ResponseTruncationMode? truncationMode = null, ResponseIncompleteStatusDetails incompleteStatusDetails = null, IEnumerable<ResponseItem> outputItems = null, bool parallelToolCallsEnabled = false, ResponseToolChoice toolChoice = null, string model = null, IDictionary<string, string> metadata = null, float? temperature = null, float? topP = null, ResponseServiceTier? serviceTier = null, string previousResponseId = null, bool? backgroundModeEnabled = null, string instructions = null, IEnumerable<ResponseTool> tools = null);
56745677
public static ReasoningResponseItem ReasoningResponseItem(string id = null, string encryptedContent = null, ReasoningStatus? status = null, IEnumerable<ReasoningSummaryPart> summaryParts = null);
56755678
public static ReasoningResponseItem ReasoningResponseItem(string id = null, string encryptedContent = null, ReasoningStatus? status = null, string summaryText = null);
56765679
public static ReferenceResponseItem ReferenceResponseItem(string id = null);
@@ -5764,10 +5767,12 @@ public enum ResponseContentPartKind {
57645767
[Experimental("OPENAI001")]
57655768
public class ResponseCreationOptions : IJsonModel<ResponseCreationOptions>, IPersistableModel<ResponseCreationOptions> {
57665769
public bool? BackgroundModeEnabled { get; set; }
5770+
public string ConversationId { get; set; }
57675771
public string EndUserId { get; set; }
57685772
public IList<IncludedResponseProperty> IncludedProperties { get; }
57695773
public string Instructions { get; set; }
57705774
public int? MaxOutputTokenCount { get; set; }
5775+
public int? MaxToolCallCount { get; set; }
57715776
public IDictionary<string, string> Metadata { get; }
57725777
public bool? ParallelToolCallsEnabled { get; set; }
57735778
[Serialization.JsonIgnore]
@@ -5776,12 +5781,14 @@ public class ResponseCreationOptions : IJsonModel<ResponseCreationOptions>, IPer
57765781
public ref JsonPatch Patch { get; }
57775782
public string PreviousResponseId { get; set; }
57785783
public ResponseReasoningOptions ReasoningOptions { get; set; }
5784+
public string SafetyIdentifier { get; set; }
57795785
public ResponseServiceTier? ServiceTier { get; set; }
57805786
public bool? StoredOutputEnabled { get; set; }
57815787
public float? Temperature { get; set; }
57825788
public ResponseTextOptions TextOptions { get; set; }
57835789
public ResponseToolChoice ToolChoice { get; set; }
57845790
public IList<ResponseTool> Tools { get; }
5791+
public int? TopLogProbabilityCount { get; set; }
57855792
public float? TopP { get; set; }
57865793
public ResponseTruncationMode? TruncationMode { get; set; }
57875794
protected virtual ResponseCreationOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);

api/OpenAI.netstandard2.0.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,7 @@ public class ChatCompletionOptions : IJsonModel<ChatCompletionOptions>, IPersist
15211521
public ChatReasoningEffortLevel? ReasoningEffortLevel { get; set; }
15221522
public ChatResponseFormat ResponseFormat { get; set; }
15231523
public ChatResponseModalities ResponseModalities { get; set; }
1524+
public string SafetyIdentifier { get; set; }
15241525
public long? Seed { get; set; }
15251526
public ChatServiceTier? ServiceTier { get; set; }
15261527
public IList<string> StopSequences { get; }
@@ -4914,6 +4915,7 @@ public class OpenAIResponse : IJsonModel<OpenAIResponse>, IPersistableModel<Open
49144915
public ResponseIncompleteStatusDetails IncompleteStatusDetails { get; }
49154916
public string Instructions { get; }
49164917
public int? MaxOutputTokenCount { get; }
4918+
public int? MaxToolCallCount { get; }
49174919
public IDictionary<string, string> Metadata { get; }
49184920
public string Model { get; }
49194921
public IList<ResponseItem> OutputItems { get; }
@@ -4981,7 +4983,7 @@ public class OpenAIResponseClient {
49814983
}
49824984
public static class OpenAIResponsesModelFactory {
49834985
public static MessageResponseItem MessageResponseItem(string id = null, MessageRole role = MessageRole.Assistant, MessageStatus? status = null);
4984-
public static OpenAIResponse OpenAIResponse(string id = null, DateTimeOffset createdAt = default, ResponseStatus? status = null, ResponseError error = null, ResponseTokenUsage usage = null, string endUserId = null, ResponseReasoningOptions reasoningOptions = null, int? maxOutputTokenCount = null, ResponseTextOptions textOptions = null, ResponseTruncationMode? truncationMode = null, ResponseIncompleteStatusDetails incompleteStatusDetails = null, IEnumerable<ResponseItem> outputItems = null, bool parallelToolCallsEnabled = false, ResponseToolChoice toolChoice = null, string model = null, IDictionary<string, string> metadata = null, float? temperature = null, float? topP = null, ResponseServiceTier? serviceTier = null, string previousResponseId = null, bool? backgroundModeEnabled = null, string instructions = null, IEnumerable<ResponseTool> tools = null);
4986+
public static OpenAIResponse OpenAIResponse(string id = null, DateTimeOffset createdAt = default, ResponseStatus? status = null, ResponseError error = null, ResponseTokenUsage usage = null, string endUserId = null, ResponseReasoningOptions reasoningOptions = null, int? maxOutputTokenCount = null, int? maxToolCallCount = null, ResponseTextOptions textOptions = null, ResponseTruncationMode? truncationMode = null, ResponseIncompleteStatusDetails incompleteStatusDetails = null, IEnumerable<ResponseItem> outputItems = null, bool parallelToolCallsEnabled = false, ResponseToolChoice toolChoice = null, string model = null, IDictionary<string, string> metadata = null, float? temperature = null, float? topP = null, ResponseServiceTier? serviceTier = null, string previousResponseId = null, bool? backgroundModeEnabled = null, string instructions = null, IEnumerable<ResponseTool> tools = null);
49854987
public static ReasoningResponseItem ReasoningResponseItem(string id = null, string encryptedContent = null, ReasoningStatus? status = null, IEnumerable<ReasoningSummaryPart> summaryParts = null);
49864988
public static ReasoningResponseItem ReasoningResponseItem(string id = null, string encryptedContent = null, ReasoningStatus? status = null, string summaryText = null);
49874989
public static ReferenceResponseItem ReferenceResponseItem(string id = null);
@@ -5065,23 +5067,27 @@ public enum ResponseContentPartKind {
50655067
}
50665068
public class ResponseCreationOptions : IJsonModel<ResponseCreationOptions>, IPersistableModel<ResponseCreationOptions> {
50675069
public bool? BackgroundModeEnabled { get; set; }
5070+
public string ConversationId { get; set; }
50685071
public string EndUserId { get; set; }
50695072
public IList<IncludedResponseProperty> IncludedProperties { get; }
50705073
public string Instructions { get; set; }
50715074
public int? MaxOutputTokenCount { get; set; }
5075+
public int? MaxToolCallCount { get; set; }
50725076
public IDictionary<string, string> Metadata { get; }
50735077
public bool? ParallelToolCallsEnabled { get; set; }
50745078
[Serialization.JsonIgnore]
50755079
[EditorBrowsable(EditorBrowsableState.Never)]
50765080
public ref JsonPatch Patch { get; }
50775081
public string PreviousResponseId { get; set; }
50785082
public ResponseReasoningOptions ReasoningOptions { get; set; }
5083+
public string SafetyIdentifier { get; set; }
50795084
public ResponseServiceTier? ServiceTier { get; set; }
50805085
public bool? StoredOutputEnabled { get; set; }
50815086
public float? Temperature { get; set; }
50825087
public ResponseTextOptions TextOptions { get; set; }
50835088
public ResponseToolChoice ToolChoice { get; set; }
50845089
public IList<ResponseTool> Tools { get; }
5090+
public int? TopLogProbabilityCount { get; set; }
50855091
public float? TopP { get; set; }
50865092
public ResponseTruncationMode? TruncationMode { get; set; }
50875093
protected virtual ResponseCreationOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);

specification/base/typespec/chat/models.tsp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,6 @@ model CreateChatCompletionRequest {
192192
search_context_size?: WebSearchContextSize = "medium";
193193
};
194194

195-
@doc("""
196-
An integer between 0 and 20 specifying the number of most likely tokens to
197-
return at each token position, each with an associated log probability.
198-
`logprobs` must be set to `true` if this parameter is used.
199-
""")
200-
@minValue(0)
201-
@maxValue(20)
202-
top_logprobs?: int32 | null;
203-
204195
// Tool customization: apply a named union type
205196
@doc("""
206197
An object specifying the format that the model must output.

specification/base/typespec/common/models.tsp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ model ModelResponsePropertiesForRequest {
249249
@minValue(0)
250250
@maxValue(2)
251251
temperature?: float32 | null = 1;
252+
253+
/** An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. */
254+
top_logprobs?: int32 | null;
252255

253256
@doc("""
254257
An alternative to sampling with temperature, called nucleus sampling,
@@ -265,6 +268,10 @@ model ModelResponsePropertiesForRequest {
265268
/** A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). */
266269
user?: string;
267270

271+
/**A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.
272+
The IDs should be a string that uniquely identifies each user. We recommend hashing their username or email address, in order to avoid sending us any identifying information. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).*/
273+
safety_identifier?: string;
274+
268275
service_tier?: ServiceTier;
269276
}
270277
model ModelResponsePropertiesForResponse {

specification/base/typespec/responses/models.tsp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,25 @@ model CreateResponse {
8787
* for more information.
8888
*/
8989
stream?: boolean | null = false;
90+
91+
/** The conversation that this response belongs to.
92+
* Items from this conversation are prepended to input_items for this response request.
93+
* Input items and output items from this response are automatically added to this conversation after this response completes. */
94+
conversation?: ConversationParam | null;
95+
}
96+
97+
/**The conversation that this response belongs to. Items from this conversation are prepended to `input_items` for this response request.
98+
Input items and output items from this response are automatically added to this conversation after this response completes.*/
99+
union ConversationParam {
100+
string,
101+
`ConversationParam-2`,
102+
}
103+
104+
/** The conversation that this response belongs to. */
105+
@summary("Conversation object")
106+
model `ConversationParam-2` {
107+
/** The unique ID of the conversation. */
108+
id: string;
90109
}
91110

92111
model Response {
@@ -178,6 +197,9 @@ model ResponseProperties {
178197
/** An upper bound for the number of tokens that can be generated for a response, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). */
179198
max_output_tokens?: int32 | null;
180199

200+
/** The maximum number of total calls to built-in tools that can be processed in a response. This maximum number applies across all built-in tool calls, not per individual tool. Any further attempts to call a tool by the model will be ignored. */
201+
max_tool_calls?: int32 | null;
202+
181203
@doc("""
182204
Inserts a system (or developer) message as the first item in the model's context.
183205

specification/client/responses.client.tsp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ using TypeSpec.HttpClient.CSharp;
88

99
@@alternateType(CreateResponse.service_tier, DotNetResponseServiceTier);
1010
@@alternateType(Response.service_tier, DotNetResponseServiceTier);
11+
@@alternateType(CreateResponse.conversation, string);
12+
@@clientName(CreateResponse.conversation, "ConversationId");
1113

1214
// ------------ ItemResources ------------
1315
@@usage(ItemResource, Usage.input | Usage.output);

src/Custom/Responses/OpenAIResponse.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public partial class OpenAIResponse
3030
[CodeGenMember("MaxOutputTokens")]
3131
public int? MaxOutputTokenCount { get; }
3232

33+
// CUSTOM: Renamed.
34+
[CodeGenMember("MaxToolCalls")]
35+
public int? MaxToolCallCount { get; }
36+
3337
// CUSTOM: Renamed.
3438
[CodeGenMember("Text")]
3539
public ResponseTextOptions TextOptions { get; }

src/Custom/Responses/OpenAIResponsesModelFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public static OpenAIResponse OpenAIResponse(
2020
string endUserId = null,
2121
ResponseReasoningOptions reasoningOptions = null,
2222
int? maxOutputTokenCount = null,
23+
int? maxToolCallCount = null,
2324
ResponseTextOptions textOptions = null,
2425
ResponseTruncationMode? truncationMode = null,
2526
ResponseIncompleteStatusDetails incompleteStatusDetails = null,
@@ -57,6 +58,7 @@ public static OpenAIResponse OpenAIResponse(
5758
endUserId: endUserId,
5859
reasoningOptions: reasoningOptions,
5960
maxOutputTokenCount: maxOutputTokenCount,
61+
maxToolCallCount: maxToolCallCount,
6062
textOptions: textOptions,
6163
truncationMode: truncationMode,
6264
incompleteStatusDetails: incompleteStatusDetails,

src/Custom/Responses/ResponseCreationOptions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public partial class ResponseCreationOptions
4545
[CodeGenMember("MaxOutputTokens")]
4646
public int? MaxOutputTokenCount { get; set; }
4747

48+
// CUSTOM: Renamed.
49+
[CodeGenMember("MaxToolCalls")]
50+
public int? MaxToolCallCount { get; set; }
51+
4852
// CUSTOM: Renamed.
4953
[CodeGenMember("Text")]
5054
public ResponseTextOptions TextOptions { get; set; }
@@ -73,6 +77,10 @@ public partial class ResponseCreationOptions
7377
[CodeGenMember("Tools")]
7478
public IList<ResponseTool> Tools { get; }
7579

80+
// CUSTOM: Renamed.
81+
[CodeGenMember("TopLogprobs")]
82+
public int? TopLogProbabilityCount { get; set; }
83+
7684
internal ResponseCreationOptions GetClone()
7785
{
7886
ResponseCreationOptions copiedOptions = (ResponseCreationOptions)this.MemberwiseClone();

0 commit comments

Comments
 (0)