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
186 changes: 186 additions & 0 deletions api/OpenAI.net8.0.cs

Large diffs are not rendered by default.

172 changes: 172 additions & 0 deletions api/OpenAI.netstandard2.0.cs

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions specification/base/typespec/responses/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,13 @@ model ImageGenTool extends Tool {
""")
background?: "transparent" | "opaque" | "auto" = "auto";

@doc("""
Control how much effort the model will exert to match the style and features,
especially facial features, of input images. This parameter is only supported
for `gpt-image-1`. Supports `high` and `low`. Defaults to `low`.
""")
input_fidelity?: "low" | "high" = "low";

@doc("""
Optional mask for inpainting. Contains `image_url`
(string, optional) and `file_id` (string, optional).
Expand All @@ -1937,7 +1944,8 @@ model ImageGenTool extends Tool {
/** An image generation request made by the model. */
alias ImageGenToolCallItemBase = {
/** The generated image encoded in base64. */
result: string | null;
@encode("base64", string)
result: bytes | null;
};

@@doc(ImageGenToolCallItemResource,
Expand Down Expand Up @@ -2285,7 +2293,8 @@ model ResponseImageGenCallPartialImageEvent extends ResponseStreamEvent {
partial_image_index: int32;

/** Base64-encoded partial image data, suitable for rendering as an image. */
partial_image_b64: string;
@encode("base64", string)
partial_image_b64: bytes;
}

// Tool customization: Remove shared sequence_number property that was moved to the common parent
Expand Down
7 changes: 6 additions & 1 deletion specification/client/responses.client.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ using Azure.ClientGenerator.Core;
@@alternateType(MCPListToolsItemResource.error, unknown | null);
@@clientName(MCPListToolsItemResource.tools, "ToolDefinitions");

@@visibility(ImageGenToolCallItemResource.status, Lifecycle.Read);
@@clientName(ImageGenToolCallItemResource.result, "GeneratedImageBytes");

// ------------ Tools ------------

@@clientName(FileSearchTool.max_num_results, "MaxResultCount");
Expand All @@ -76,4 +79,6 @@ using Azure.ClientGenerator.Core;
@@alternateType(ResponseMCPCallArgumentsDoneEvent.arguments, unknown);
// @@clientName(ResponseMCPCallArgumentsDoneEvent.arguments, "ToolArguments");

@@alternateType(ResponseMCPCallArgumentsDeltaEvent.delta, unknown);
@@alternateType(ResponseMCPCallArgumentsDeltaEvent.delta, unknown);

@@clientName(ResponseImageGenCallPartialImageEvent.partial_image_b64, "PartialImageBytes");
14 changes: 0 additions & 14 deletions src/Custom/Responses/Internal/GeneratorStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,12 @@ namespace OpenAI.Responses;
[CodeGenType("UnknownTool")] internal partial class InternalUnknownTool {}
[CodeGenType("UnknownToolChoiceObject")] internal partial class InternalUnknownToolChoiceObject {}
[CodeGenType("WebSearchToolCallItemParam")] internal partial class InternalWebSearchToolCallItemParam {}
[CodeGenType("ImageGenToolModel")] internal readonly partial struct InternalImageGenToolModel {}
[CodeGenType("ImageGenToolQuality")] internal readonly partial struct InternalImageGenToolQuality {}
[CodeGenType("ImageGenToolSize")] internal readonly partial struct InternalImageGenToolSize {}
[CodeGenType("ImageGenToolOutputFormat")] internal readonly partial struct InternalImageGenToolOutputFormat {}
[CodeGenType("ImageGenToolModeration")] internal readonly partial struct InternalImageGenToolModeration {}
[CodeGenType("ImageGenToolBackground")] internal readonly partial struct InternalImageGenToolBackground {}
[CodeGenType("CodeInterpreterFileOutputType")] internal readonly partial struct InternalCodeInterpreterFileOutputType {}
[CodeGenType("CodeInterpreterTextOutputType")] internal readonly partial struct InternalCodeInterpreterTextOutputType {}
[CodeGenType("CodeInterpreterToolOutputType")] internal readonly partial struct InternalCodeInterpreterToolOutputType {}
[CodeGenType("LocalShellExecActionType")] internal readonly partial struct InternalLocalShellExecActionType {}
[CodeGenType("ImageGenToolCallItemResourceStatus")] internal readonly partial struct InternalImageGenToolCallItemResourceStatus {}
[CodeGenType("LocalShellToolCallItemResourceStatus")] internal readonly partial struct InternalLocalShellToolCallItemResourceStatus {}
[CodeGenType("LocalShellToolCallOutputItemResourceStatus")] internal readonly partial struct InternalLocalShellToolCallOutputItemResourceStatus {}
[CodeGenType("ImageGenTool")] internal partial class InternalImageGenTool {}
[CodeGenType("ImageGenToolInputImageMask")] internal partial class InternalImageGenToolInputImageMask {}
[CodeGenType("LocalShellTool")] internal partial class InternalLocalShellTool {}
[CodeGenType("MCPToolRequireApproval1")] internal partial class InternalMCPToolRequireApproval1 {}
[CodeGenType("MCPToolRequireApprovalAlways")] internal partial class InternalMCPToolRequireApprovalAlways {}
Expand All @@ -124,13 +115,8 @@ namespace OpenAI.Responses;
[CodeGenType("MCPApprovalRequestItemParam")] internal partial class InternalMCPApprovalRequestItemParam {}
[CodeGenType("MCPApprovalResponseItemParam")] internal partial class InternalMCPApprovalResponseItemParam {}
[CodeGenType("MCPCallItemParam")] internal partial class InternalMCPCallItemParam {}
[CodeGenType("ImageGenToolCallItemResource")] internal partial class InternalImageGenToolCallItemResource {}
[CodeGenType("LocalShellToolCallItemResource")] internal partial class InternalLocalShellToolCallItemResource {}
[CodeGenType("LocalShellToolCallOutputItemResource")] internal partial class InternalLocalShellToolCallOutputItemResource {}
[CodeGenType("ResponseImageGenCallCompletedEvent")] internal partial class InternalResponseImageGenCallCompletedEvent {}
[CodeGenType("ResponseImageGenCallGeneratingEvent")] internal partial class InternalResponseImageGenCallGeneratingEvent {}
[CodeGenType("ResponseImageGenCallInProgressEvent")] internal partial class InternalResponseImageGenCallInProgressEvent {}
[CodeGenType("ResponseImageGenCallPartialImageEvent")] internal partial class InternalResponseImageGenCallPartialImageEvent {}
[CodeGenType("ResponseReasoningDeltaEvent")] internal partial class InternalResponseReasoningDeltaEvent {}
[CodeGenType("ResponseReasoningDoneEvent")] internal partial class InternalResponseReasoningDoneEvent {}
[CodeGenType("ResponseReasoningSummaryDeltaEvent")] internal partial class InternalResponseReasoningSummaryDeltaEvent {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ImageGenToolCallItemResource")]
public partial class ImageGenerationCallResponseItem
{
// CUSTOM: Made nullable since this is a read-only property.
[CodeGenMember("Status")]
public ImageGenerationCallStatus? Status { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Diagnostics.CodeAnalysis;

namespace OpenAI.Responses;

// CUSTOM: Renamed.
[Experimental("OPENAI001")]
[CodeGenType("ImageGenToolCallItemResourceStatus")]
public enum ImageGenerationCallStatus
{
InProgress,
Completed,
Generating,
Failed
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ResponseImageGenCallCompletedEvent")]
public partial class StreamingResponseImageGenerationCallCompletedUpdate
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ResponseImageGenCallGeneratingEvent")]
public partial class StreamingResponseImageGenerationCallGeneratingUpdate
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ResponseImageGenCallInProgressEvent")]
public partial class StreamingResponseImageGenerationCallInProgressUpdate
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ResponseImageGenCallPartialImageEvent")]
public partial class StreamingResponseImageGenerationCallPartialImageUpdate
{
}
28 changes: 28 additions & 0 deletions src/Custom/Responses/Tools/ImageGenerationTool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Diagnostics.CodeAnalysis;

namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ImageGenTool")]
public partial class ImageGenerationTool
{
// CUSTOM:Renamed.
[CodeGenMember("OutputCompression")]
public int? OutputCompressionFactor { get; set; }

// CUSTOM: Renamed.
[CodeGenMember("OutputFormat")]
public ImageGenerationToolOutputFileFormat? OutputFileFormat { get; set; }

// CUSTOM: Renamed.
[CodeGenMember("Moderation")]
public ImageGenerationToolModerationLevel? ModerationLevel { get; set; }

// CUSTOM: Renamed.
[CodeGenMember("InputFidelity")]
public ImageGenerationToolInputFidelityLevel? InputFidelityLevel { get; set; }

// CUSTOM:Renamed.
[CodeGenMember("PartialImages")]
public int? PartialImageCount { get; set; }
}
7 changes: 7 additions & 0 deletions src/Custom/Responses/Tools/ImageGenerationToolBackground.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ImageGenToolBackground")]
public readonly partial struct ImageGenerationToolBackground
{
}
41 changes: 41 additions & 0 deletions src/Custom/Responses/Tools/ImageGenerationToolInputImageMask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;

namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ImageGenToolInputImageMask")]
public partial class ImageGenerationToolInputImageMask
{
internal ImageGenerationToolInputImageMask() { }

public ImageGenerationToolInputImageMask(string fileId)
{
Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));

FileId = fileId;
}

public ImageGenerationToolInputImageMask(BinaryData imageBytes, string imageBytesMediaType)
{
Argument.AssertNotNull(imageBytes, nameof(imageBytes));
Argument.AssertNotNullOrEmpty(imageBytesMediaType, nameof(imageBytesMediaType));

string base64EncodedData = Convert.ToBase64String(imageBytes.ToArray());
ImageUrl = $"data:{imageBytesMediaType};base64,{base64EncodedData}";
}

public ImageGenerationToolInputImageMask(Uri imageUri)
{
Argument.AssertNotNull(imageUri, nameof(imageUri));

ImageUrl = imageUri?.AbsoluteUri;
}

// CUSTOM: Removed setter.
[CodeGenMember("ImageUrl")]
public string ImageUrl { get; }

// CUSTOM: Removed setter.
[CodeGenMember("FileId")]
public string FileId { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ImageGenToolInputFidelity")]
public readonly partial struct ImageGenerationToolInputFidelityLevel
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ImageGenToolModeration")]
public readonly partial struct ImageGenerationToolModerationLevel
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ImageGenToolOutputFormat")]
public readonly partial struct ImageGenerationToolOutputFileFormat
{
}
7 changes: 7 additions & 0 deletions src/Custom/Responses/Tools/ImageGenerationToolQuality.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenAI.Responses;

// CUSTOM: Renamed.
[CodeGenType("ImageGenToolQuality")]
public readonly partial struct ImageGenerationToolQuality
{
}
62 changes: 62 additions & 0 deletions src/Custom/Responses/Tools/ImageGenerationToolSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Diagnostics.CodeAnalysis;

namespace OpenAI.Responses;

// CUSTOM: Added custom struct in favor of the generated extensible enum.
/// <summary> The size of the image that will be generated. </summary>
[CodeGenType("ImageGenToolSize")]
[CodeGenSuppress("GeneratedImageSize", typeof(string))]
// CUSTOM: remove the implicit operator
[CodeGenSuppress("", typeof(string))]
public readonly partial struct ImageGenerationToolSize
{

/// <summary> Initializes a new instance of <see cref="ImageGenerationToolSize"/>. </summary>
/// <exception cref="ArgumentNullException"> <paramref name="value"/> is null. </exception>
internal ImageGenerationToolSize(string value)
{
_value = value ?? throw new ArgumentNullException(nameof(value));
}

/// <summary>
/// Creates a new instance of <see cref="ImageGenerationToolSize"/>.
/// </summary>
/// <remarks>
/// <b>Note:</b> arbitrary dimensions are not supported and a given model will only support a set of predefined
/// sizes. If supported dimensions are not known, try using one of the static properties like <see cref="W1024xH1024"/>.
/// </remarks>
/// <param name="width"> The desired width, in pixels, for an image. </param>
/// <param name="height"> The desired height, in pixels, for an image. </param>
public ImageGenerationToolSize(int width, int height)
{
_value = $"{width}x{height}";
}

/// <summary>
/// A square image with 1024 pixels of both width and height.
/// <para>
/// <b>Supported</b> and <b>default</b> for both <c>dall-e-2</c> and <c>dall-e-3</c> models.
/// </para>
/// </summary>
[CodeGenMember("_1024x1024")]
public static readonly ImageGenerationToolSize W1024xH1024 = new ImageGenerationToolSize(1024, 1024);

/// <summary>
/// An extra tall image, 1024 pixels wide by 1536 pixels high.
/// <para>
/// Supported <b>only</b> for the <c>dall-e-3</c> model.
/// </para>
/// </summary>
[CodeGenMember("_1024x1536")]
public static readonly ImageGenerationToolSize W1024xH1536 = new(1024, 1536);

/// <summary>
/// An extra wide image, 1536 pixels wide by 1024 pixels high.
/// <para>
/// Supported <b>only</b> for the <c>dall-e-3</c> model.
/// </para>
/// </summary>
[CodeGenMember("_1536x1024")]
public static readonly ImageGenerationToolSize W1536xH1024 = new(1536, 1024);
}
21 changes: 21 additions & 0 deletions src/Custom/Responses/Tools/ResponseTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,25 @@ public static CodeInterpreterTool CreateCodeInterpreterTool(CodeInterpreterConta
additionalBinaryDataProperties: null,
container: container);
}

// CUSTOM: Added factory method for a convenience.
/// <summary>
/// Creates a new instance of the <see cref="ImageGenerationTool"/> class.
/// </summary>
public static ImageGenerationTool CreateImageGenerationTool(string model, ImageGenerationToolQuality? quality = null, ImageGenerationToolSize? size = null, ImageGenerationToolOutputFileFormat? outputFileFormat = null, int? outputCompressionFactor = null, ImageGenerationToolModerationLevel? moderationLevel = null, ImageGenerationToolBackground? background = null, ImageGenerationToolInputFidelityLevel? inputFidelityLevel = null, ImageGenerationToolInputImageMask inputImageMask = null, int? partialImageCount = null)
{
return new ImageGenerationTool(
kind: InternalToolType.ImageGeneration,
additionalBinaryDataProperties: null,
model: model,
quality: quality,
size: size,
outputFileFormat: outputFileFormat,
outputCompressionFactor: outputCompressionFactor,
moderationLevel: moderationLevel,
background: background,
inputFidelityLevel: inputFidelityLevel,
inputImageMask: inputImageMask,
partialImageCount: partialImageCount);
}
}
14 changes: 7 additions & 7 deletions src/Generated/Models/OpenAIContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ namespace OpenAI
[ModelReaderWriterBuildable(typeof(HyperparametersForDPO))]
[ModelReaderWriterBuildable(typeof(HyperparametersForSupervised))]
[ModelReaderWriterBuildable(typeof(ImageEditOptions))]
[ModelReaderWriterBuildable(typeof(ImageGenerationCallResponseItem))]
[ModelReaderWriterBuildable(typeof(ImageGenerationOptions))]
[ModelReaderWriterBuildable(typeof(ImageGenerationTool))]
[ModelReaderWriterBuildable(typeof(ImageGenerationToolInputImageMask))]
[ModelReaderWriterBuildable(typeof(ImageInputTokenUsageDetails))]
[ModelReaderWriterBuildable(typeof(ImageTokenUsage))]
[ModelReaderWriterBuildable(typeof(ImageVariationOptions))]
Expand Down Expand Up @@ -338,10 +341,7 @@ namespace OpenAI
[ModelReaderWriterBuildable(typeof(InternalFunctionDefinition))]
[ModelReaderWriterBuildable(typeof(InternalFunctionToolCallItemParam))]
[ModelReaderWriterBuildable(typeof(InternalFunctionToolCallOutputItemParam))]
[ModelReaderWriterBuildable(typeof(InternalImageGenTool))]
[ModelReaderWriterBuildable(typeof(InternalImageGenToolCallItemParam))]
[ModelReaderWriterBuildable(typeof(InternalImageGenToolCallItemResource))]
[ModelReaderWriterBuildable(typeof(InternalImageGenToolInputImageMask))]
[ModelReaderWriterBuildable(typeof(InternalImplicitUserMessage))]
[ModelReaderWriterBuildable(typeof(InternalItemContentInputAudio))]
[ModelReaderWriterBuildable(typeof(InternalItemContentInputFile))]
Expand Down Expand Up @@ -493,10 +493,6 @@ namespace OpenAI
[ModelReaderWriterBuildable(typeof(InternalResponseFormatJsonSchemaJsonSchema))]
[ModelReaderWriterBuildable(typeof(InternalResponseFormatJsonSchemaSchema))]
[ModelReaderWriterBuildable(typeof(InternalResponseFormatText))]
[ModelReaderWriterBuildable(typeof(InternalResponseImageGenCallCompletedEvent))]
[ModelReaderWriterBuildable(typeof(InternalResponseImageGenCallGeneratingEvent))]
[ModelReaderWriterBuildable(typeof(InternalResponseImageGenCallInProgressEvent))]
[ModelReaderWriterBuildable(typeof(InternalResponseImageGenCallPartialImageEvent))]
[ModelReaderWriterBuildable(typeof(InternalResponseItemList))]
[ModelReaderWriterBuildable(typeof(InternalResponseReasoningDeltaEvent))]
[ModelReaderWriterBuildable(typeof(InternalResponseReasoningDoneEvent))]
Expand Down Expand Up @@ -731,6 +727,10 @@ namespace OpenAI
[ModelReaderWriterBuildable(typeof(StreamingResponseFileSearchCallSearchingUpdate))]
[ModelReaderWriterBuildable(typeof(StreamingResponseFunctionCallArgumentsDeltaUpdate))]
[ModelReaderWriterBuildable(typeof(StreamingResponseFunctionCallArgumentsDoneUpdate))]
[ModelReaderWriterBuildable(typeof(StreamingResponseImageGenerationCallCompletedUpdate))]
[ModelReaderWriterBuildable(typeof(StreamingResponseImageGenerationCallGeneratingUpdate))]
[ModelReaderWriterBuildable(typeof(StreamingResponseImageGenerationCallInProgressUpdate))]
[ModelReaderWriterBuildable(typeof(StreamingResponseImageGenerationCallPartialImageUpdate))]
[ModelReaderWriterBuildable(typeof(StreamingResponseIncompleteUpdate))]
[ModelReaderWriterBuildable(typeof(StreamingResponseInProgressUpdate))]
[ModelReaderWriterBuildable(typeof(StreamingResponseMcpCallArgumentsDeltaUpdate))]
Expand Down
Loading