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
12 changes: 12 additions & 0 deletions api/OpenAI.net8.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ public class AudioClient {
public AudioClient(string model, ApiKeyCredential credential, OpenAIClientOptions options);
public AudioClient(string model, ApiKeyCredential credential);
public AudioClient(string model, string apiKey);
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult GenerateSpeech(BinaryContent content, RequestOptions options = null);
public virtual ClientResult<BinaryData> GenerateSpeech(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -1403,6 +1404,7 @@ public class ChatClient {
public ChatClient(string model, ApiKeyCredential credential, OpenAIClientOptions options);
public ChatClient(string model, ApiKeyCredential credential);
public ChatClient(string model, string apiKey);
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult<ChatCompletion> CompleteChat(params ChatMessage[] messages);
public virtual ClientResult CompleteChat(BinaryContent content, RequestOptions options = null);
Expand Down Expand Up @@ -2242,6 +2244,7 @@ public class EmbeddingClient {
public EmbeddingClient(string model, ApiKeyCredential credential, OpenAIClientOptions options);
public EmbeddingClient(string model, ApiKeyCredential credential);
public EmbeddingClient(string model, string apiKey);
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult<OpenAIEmbedding> GenerateEmbedding(string input, EmbeddingGenerationOptions options = null, CancellationToken cancellationToken = default);
public virtual Task<ClientResult<OpenAIEmbedding>> GenerateEmbeddingAsync(string input, EmbeddingGenerationOptions options = null, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -3204,6 +3207,7 @@ public class ImageClient {
public ImageClient(string model, ApiKeyCredential credential, OpenAIClientOptions options);
public ImageClient(string model, ApiKeyCredential credential);
public ImageClient(string model, string apiKey);
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult<GeneratedImage> GenerateImage(string prompt, ImageGenerationOptions options = null, CancellationToken cancellationToken = default);
public virtual Task<ClientResult<GeneratedImage>> GenerateImageAsync(string prompt, ImageGenerationOptions options = null, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -3390,6 +3394,7 @@ public class ModerationClient {
public ModerationClient(string model, ApiKeyCredential credential, OpenAIClientOptions options);
public ModerationClient(string model, ApiKeyCredential credential);
public ModerationClient(string model, string apiKey);
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult ClassifyText(BinaryContent content, RequestOptions options = null);
public virtual ClientResult<ModerationResultCollection> ClassifyText(IEnumerable<string> inputs, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -4570,6 +4575,13 @@ public class OpenAIResponseClient {
public virtual CollectionResult<StreamingResponseUpdate> GetResponseStreaming(string responseId, int? startingAfter = null, CancellationToken cancellationToken = default);
public virtual AsyncCollectionResult<StreamingResponseUpdate> GetResponseStreamingAsync(string responseId, int? startingAfter = null, CancellationToken cancellationToken = default);
}
public static class OpenAIResponsesModelFactory {
public static MessageResponseItem MessageResponseItem(string id = null, MessageRole role = MessageRole.Assistant, MessageStatus? status = null);
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, string previousResponseId = null, bool? background = null, string instructions = null, IEnumerable<ResponseTool> tools = null);
public static ReasoningResponseItem ReasoningResponseItem(string id = null, string encryptedContent = null, ReasoningStatus? status = null, IEnumerable<ReasoningSummaryPart> summaryParts = null);
public static ReasoningResponseItem ReasoningResponseItem(string id = null, string encryptedContent = null, ReasoningStatus? status = null, string summaryText = null);
public static ReferenceResponseItem ReferenceResponseItem(string id = null);
}
[Experimental("OPENAI001")]
public class ReasoningResponseItem : ResponseItem, IJsonModel<ReasoningResponseItem>, IPersistableModel<ReasoningResponseItem> {
public ReasoningResponseItem(IEnumerable<ReasoningSummaryPart> summaryParts);
Expand Down
12 changes: 12 additions & 0 deletions api/OpenAI.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ public class AudioClient {
public AudioClient(string model, ApiKeyCredential credential, OpenAIClientOptions options);
public AudioClient(string model, ApiKeyCredential credential);
public AudioClient(string model, string apiKey);
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult GenerateSpeech(BinaryContent content, RequestOptions options = null);
public virtual ClientResult<BinaryData> GenerateSpeech(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -1266,6 +1267,7 @@ public class ChatClient {
public ChatClient(string model, ApiKeyCredential credential, OpenAIClientOptions options);
public ChatClient(string model, ApiKeyCredential credential);
public ChatClient(string model, string apiKey);
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult<ChatCompletion> CompleteChat(params ChatMessage[] messages);
public virtual ClientResult CompleteChat(BinaryContent content, RequestOptions options = null);
Expand Down Expand Up @@ -1951,6 +1953,7 @@ public class EmbeddingClient {
public EmbeddingClient(string model, ApiKeyCredential credential, OpenAIClientOptions options);
public EmbeddingClient(string model, ApiKeyCredential credential);
public EmbeddingClient(string model, string apiKey);
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult<OpenAIEmbedding> GenerateEmbedding(string input, EmbeddingGenerationOptions options = null, CancellationToken cancellationToken = default);
public virtual Task<ClientResult<OpenAIEmbedding>> GenerateEmbeddingAsync(string input, EmbeddingGenerationOptions options = null, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -2811,6 +2814,7 @@ public class ImageClient {
public ImageClient(string model, ApiKeyCredential credential, OpenAIClientOptions options);
public ImageClient(string model, ApiKeyCredential credential);
public ImageClient(string model, string apiKey);
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult<GeneratedImage> GenerateImage(string prompt, ImageGenerationOptions options = null, CancellationToken cancellationToken = default);
public virtual Task<ClientResult<GeneratedImage>> GenerateImageAsync(string prompt, ImageGenerationOptions options = null, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -2966,6 +2970,7 @@ public class ModerationClient {
public ModerationClient(string model, ApiKeyCredential credential, OpenAIClientOptions options);
public ModerationClient(string model, ApiKeyCredential credential);
public ModerationClient(string model, string apiKey);
public string Model { get; }
public ClientPipeline Pipeline { get; }
public virtual ClientResult ClassifyText(BinaryContent content, RequestOptions options = null);
public virtual ClientResult<ModerationResultCollection> ClassifyText(IEnumerable<string> inputs, CancellationToken cancellationToken = default);
Expand Down Expand Up @@ -4052,6 +4057,13 @@ public class OpenAIResponseClient {
public virtual CollectionResult<StreamingResponseUpdate> GetResponseStreaming(string responseId, int? startingAfter = null, CancellationToken cancellationToken = default);
public virtual AsyncCollectionResult<StreamingResponseUpdate> GetResponseStreamingAsync(string responseId, int? startingAfter = null, CancellationToken cancellationToken = default);
}
public static class OpenAIResponsesModelFactory {
public static MessageResponseItem MessageResponseItem(string id = null, MessageRole role = MessageRole.Assistant, MessageStatus? status = null);
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, string previousResponseId = null, bool? background = null, string instructions = null, IEnumerable<ResponseTool> tools = null);
public static ReasoningResponseItem ReasoningResponseItem(string id = null, string encryptedContent = null, ReasoningStatus? status = null, IEnumerable<ReasoningSummaryPart> summaryParts = null);
public static ReasoningResponseItem ReasoningResponseItem(string id = null, string encryptedContent = null, ReasoningStatus? status = null, string summaryText = null);
public static ReferenceResponseItem ReferenceResponseItem(string id = null);
}
public class ReasoningResponseItem : ResponseItem, IJsonModel<ReasoningResponseItem>, IPersistableModel<ReasoningResponseItem> {
public ReasoningResponseItem(IEnumerable<ReasoningSummaryPart> summaryParts);
public ReasoningResponseItem(string summaryText);
Expand Down
3 changes: 1 addition & 2 deletions src/Custom/Responses/Items/ReasoningResponseItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace OpenAI.Responses;
Expand All @@ -12,7 +11,7 @@ public partial class ReasoningResponseItem
{
// CUSTOM: Retain optionality of OpenAPI read-only property value
[CodeGenMember("Status")]
public ReasoningStatus? Status { get; }
public ReasoningStatus? Status { get; internal set; }

// CUSTOM: Rename for collection clarity
[CodeGenMember("Summary")]
Expand Down
148 changes: 148 additions & 0 deletions src/Custom/Responses/OpenAIResponsesModelFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace OpenAI.Responses;

/// <summary> Model factory for models. </summary>
[Experimental("OPENAI001")]
public static partial class OpenAIResponsesModelFactory
{
/// <summary> Initializes a new instance of <see cref="OpenAI.Responses.OpenAIResponse"/>. </summary>
/// <returns> A new <see cref="OpenAI.Responses.OpenAIResponse"/> instance for mocking. </returns>
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 = default,
ResponseToolChoice toolChoice = null,
string model = null,
IDictionary<string, string> metadata = null,
float? temperature = null,
float? topP = null,
string previousResponseId = null,
bool? background = null,
string instructions = null,
IEnumerable<ResponseTool> tools = null)
{
outputItems ??= new List<ResponseItem>();
tools ??= new List<ResponseTool>();
metadata ??= new Dictionary<string, string>();

return new OpenAIResponse(
metadata: metadata,
temperature: temperature,
topP: topP,
serviceTier: null,
previousResponseId: previousResponseId,
background: background,
instructions: instructions,
tools: tools.ToList(),
id: id,
status: status,
createdAt: createdAt,
error: error,
usage: usage,
endUserId: endUserId,
reasoningOptions: reasoningOptions,
maxOutputTokenCount: maxOutputTokenCount,
textOptions: textOptions,
truncationMode: truncationMode,
incompleteStatusDetails: incompleteStatusDetails,
outputItems: outputItems.ToList(),
parallelToolCallsEnabled: parallelToolCallsEnabled,
toolChoice: toolChoice,
model: model,
@object: "response",
additionalBinaryDataProperties: null);
}

/// <summary> Initializes a new instance of <see cref="OpenAI.Responses.MessageResponseItem"/>. </summary>
/// <returns> A new <see cref="OpenAI.Responses.MessageResponseItem"/> instance for mocking. </returns>
public static MessageResponseItem MessageResponseItem(
string id = null,
MessageRole role = MessageRole.Assistant,
MessageStatus? status = null)
{
// Convert the public MessageRole to the internal role type
InternalResponsesMessageRole internalRole = role.ToSerialString();

return new MessageResponseItem(
id: id,
internalRole: internalRole,
status: status);
}

/// <summary> Initializes a new instance of <see cref="OpenAI.Responses.ReasoningResponseItem"/>. </summary>
/// <param name="id">The ID of the reasoning response item.</param>
/// <param name="encryptedContent">The encrypted reasoning content.</param>
/// <param name="status">The status of the reasoning response item.</param>
/// <param name="summaryParts">The collection of summary parts.</param>
/// <returns> A new <see cref="OpenAI.Responses.ReasoningResponseItem"/> instance for mocking. </returns>
public static ReasoningResponseItem ReasoningResponseItem(
string id = null,
string encryptedContent = null,
ReasoningStatus? status = null,
IEnumerable<ReasoningSummaryPart> summaryParts = null)
{
summaryParts ??= new List<ReasoningSummaryPart>();

var item = new ReasoningResponseItem(
kind: InternalItemType.Reasoning,
id: id,
additionalBinaryDataProperties: null,
encryptedContent: encryptedContent,
summaryParts: summaryParts.ToList());

item.Status = status;
return item;
}

/// <summary> Initializes a new instance of <see cref="OpenAI.Responses.ReasoningResponseItem"/> with summary text. </summary>
/// <param name="id">The ID of the reasoning response item.</param>
/// <param name="encryptedContent">The encrypted reasoning content.</param>
/// <param name="status">The status of the reasoning response item.</param>
/// <param name="summaryText">The summary text to create a ReasoningSummaryTextPart from.</param>
/// <returns> A new <see cref="OpenAI.Responses.ReasoningResponseItem"/> instance for mocking. </returns>
public static ReasoningResponseItem ReasoningResponseItem(
string id = null,
string encryptedContent = null,
ReasoningStatus? status = null,
string summaryText = null)
{
var summaryParts = !string.IsNullOrEmpty(summaryText)
? new List<ReasoningSummaryPart> { new ReasoningSummaryTextPart(summaryText) }
: new List<ReasoningSummaryPart>();

var item = new ReasoningResponseItem(
kind: InternalItemType.Reasoning,
id: id,
additionalBinaryDataProperties: null,
encryptedContent: encryptedContent,
summaryParts: summaryParts);

item.Status = status;
return item;
}

/// <summary> Initializes a new instance of <see cref="OpenAI.Responses.ReferenceResponseItem"/>. </summary>
/// <returns> A new <see cref="OpenAI.Responses.ReferenceResponseItem"/> instance for mocking. </returns>
public static ReferenceResponseItem ReferenceResponseItem(
string id = null)
{
return new ReferenceResponseItem(
kind: InternalItemType.ItemReference,
id: id,
additionalBinaryDataProperties: null);
}
}
Loading