Skip to content

Commit 0d2927b

Browse files
authored
Expose ImageGenerationTool for responses (#702)
1 parent dc7f318 commit 0d2927b

File tree

62 files changed

+13929
-12985
lines changed

Some content is hidden

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

62 files changed

+13929
-12985
lines changed

api/OpenAI.net8.0.cs

Lines changed: 186 additions & 0 deletions
Large diffs are not rendered by default.

api/OpenAI.netstandard2.0.cs

Lines changed: 172 additions & 0 deletions
Large diffs are not rendered by default.

specification/base/typespec/responses/models.tsp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,13 @@ model ImageGenTool extends Tool {
19151915
""")
19161916
background?: "transparent" | "opaque" | "auto" = "auto";
19171917

1918+
@doc("""
1919+
Control how much effort the model will exert to match the style and features,
1920+
especially facial features, of input images. This parameter is only supported
1921+
for `gpt-image-1`. Supports `high` and `low`. Defaults to `low`.
1922+
""")
1923+
input_fidelity?: "low" | "high" = "low";
1924+
19181925
@doc("""
19191926
Optional mask for inpainting. Contains `image_url`
19201927
(string, optional) and `file_id` (string, optional).
@@ -1937,7 +1944,8 @@ model ImageGenTool extends Tool {
19371944
/** An image generation request made by the model. */
19381945
alias ImageGenToolCallItemBase = {
19391946
/** The generated image encoded in base64. */
1940-
result: string | null;
1947+
@encode("base64", string)
1948+
result: bytes | null;
19411949
};
19421950

19431951
@@doc(ImageGenToolCallItemResource,
@@ -2285,7 +2293,8 @@ model ResponseImageGenCallPartialImageEvent extends ResponseStreamEvent {
22852293
partial_image_index: int32;
22862294

22872295
/** Base64-encoded partial image data, suitable for rendering as an image. */
2288-
partial_image_b64: string;
2296+
@encode("base64", string)
2297+
partial_image_b64: bytes;
22892298
}
22902299

22912300
// Tool customization: Remove shared sequence_number property that was moved to the common parent

specification/client/responses.client.tsp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ using Azure.ClientGenerator.Core;
5050
@@alternateType(MCPListToolsItemResource.error, unknown | null);
5151
@@clientName(MCPListToolsItemResource.tools, "ToolDefinitions");
5252

53+
@@visibility(ImageGenToolCallItemResource.status, Lifecycle.Read);
54+
@@clientName(ImageGenToolCallItemResource.result, "GeneratedImageBytes");
55+
5356
// ------------ Tools ------------
5457

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

79-
@@alternateType(ResponseMCPCallArgumentsDeltaEvent.delta, unknown);
82+
@@alternateType(ResponseMCPCallArgumentsDeltaEvent.delta, unknown);
83+
84+
@@clientName(ResponseImageGenCallPartialImageEvent.partial_image_b64, "PartialImageBytes");

src/Custom/Responses/Internal/GeneratorStubs.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,12 @@ namespace OpenAI.Responses;
9191
[CodeGenType("UnknownTool")] internal partial class InternalUnknownTool {}
9292
[CodeGenType("UnknownToolChoiceObject")] internal partial class InternalUnknownToolChoiceObject {}
9393
[CodeGenType("WebSearchToolCallItemParam")] internal partial class InternalWebSearchToolCallItemParam {}
94-
[CodeGenType("ImageGenToolModel")] internal readonly partial struct InternalImageGenToolModel {}
95-
[CodeGenType("ImageGenToolQuality")] internal readonly partial struct InternalImageGenToolQuality {}
96-
[CodeGenType("ImageGenToolSize")] internal readonly partial struct InternalImageGenToolSize {}
97-
[CodeGenType("ImageGenToolOutputFormat")] internal readonly partial struct InternalImageGenToolOutputFormat {}
98-
[CodeGenType("ImageGenToolModeration")] internal readonly partial struct InternalImageGenToolModeration {}
99-
[CodeGenType("ImageGenToolBackground")] internal readonly partial struct InternalImageGenToolBackground {}
10094
[CodeGenType("CodeInterpreterFileOutputType")] internal readonly partial struct InternalCodeInterpreterFileOutputType {}
10195
[CodeGenType("CodeInterpreterTextOutputType")] internal readonly partial struct InternalCodeInterpreterTextOutputType {}
10296
[CodeGenType("CodeInterpreterToolOutputType")] internal readonly partial struct InternalCodeInterpreterToolOutputType {}
10397
[CodeGenType("LocalShellExecActionType")] internal readonly partial struct InternalLocalShellExecActionType {}
104-
[CodeGenType("ImageGenToolCallItemResourceStatus")] internal readonly partial struct InternalImageGenToolCallItemResourceStatus {}
10598
[CodeGenType("LocalShellToolCallItemResourceStatus")] internal readonly partial struct InternalLocalShellToolCallItemResourceStatus {}
10699
[CodeGenType("LocalShellToolCallOutputItemResourceStatus")] internal readonly partial struct InternalLocalShellToolCallOutputItemResourceStatus {}
107-
[CodeGenType("ImageGenTool")] internal partial class InternalImageGenTool {}
108-
[CodeGenType("ImageGenToolInputImageMask")] internal partial class InternalImageGenToolInputImageMask {}
109100
[CodeGenType("LocalShellTool")] internal partial class InternalLocalShellTool {}
110101
[CodeGenType("MCPToolRequireApproval1")] internal partial class InternalMCPToolRequireApproval1 {}
111102
[CodeGenType("MCPToolRequireApprovalAlways")] internal partial class InternalMCPToolRequireApprovalAlways {}
@@ -124,13 +115,8 @@ namespace OpenAI.Responses;
124115
[CodeGenType("MCPApprovalRequestItemParam")] internal partial class InternalMCPApprovalRequestItemParam {}
125116
[CodeGenType("MCPApprovalResponseItemParam")] internal partial class InternalMCPApprovalResponseItemParam {}
126117
[CodeGenType("MCPCallItemParam")] internal partial class InternalMCPCallItemParam {}
127-
[CodeGenType("ImageGenToolCallItemResource")] internal partial class InternalImageGenToolCallItemResource {}
128118
[CodeGenType("LocalShellToolCallItemResource")] internal partial class InternalLocalShellToolCallItemResource {}
129119
[CodeGenType("LocalShellToolCallOutputItemResource")] internal partial class InternalLocalShellToolCallOutputItemResource {}
130-
[CodeGenType("ResponseImageGenCallCompletedEvent")] internal partial class InternalResponseImageGenCallCompletedEvent {}
131-
[CodeGenType("ResponseImageGenCallGeneratingEvent")] internal partial class InternalResponseImageGenCallGeneratingEvent {}
132-
[CodeGenType("ResponseImageGenCallInProgressEvent")] internal partial class InternalResponseImageGenCallInProgressEvent {}
133-
[CodeGenType("ResponseImageGenCallPartialImageEvent")] internal partial class InternalResponseImageGenCallPartialImageEvent {}
134120
[CodeGenType("ResponseReasoningDeltaEvent")] internal partial class InternalResponseReasoningDeltaEvent {}
135121
[CodeGenType("ResponseReasoningDoneEvent")] internal partial class InternalResponseReasoningDoneEvent {}
136122
[CodeGenType("ResponseReasoningSummaryDeltaEvent")] internal partial class InternalResponseReasoningSummaryDeltaEvent {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace OpenAI.Responses;
2+
3+
// CUSTOM: Renamed.
4+
[CodeGenType("ImageGenToolCallItemResource")]
5+
public partial class ImageGenerationCallResponseItem
6+
{
7+
// CUSTOM: Made nullable since this is a read-only property.
8+
[CodeGenMember("Status")]
9+
public ImageGenerationCallStatus? Status { get; }
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace OpenAI.Responses;
4+
5+
// CUSTOM: Renamed.
6+
[Experimental("OPENAI001")]
7+
[CodeGenType("ImageGenToolCallItemResourceStatus")]
8+
public enum ImageGenerationCallStatus
9+
{
10+
InProgress,
11+
Completed,
12+
Generating,
13+
Failed
14+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace OpenAI.Responses;
2+
3+
// CUSTOM: Renamed.
4+
[CodeGenType("ResponseImageGenCallCompletedEvent")]
5+
public partial class StreamingResponseImageGenerationCallCompletedUpdate
6+
{
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace OpenAI.Responses;
2+
3+
// CUSTOM: Renamed.
4+
[CodeGenType("ResponseImageGenCallGeneratingEvent")]
5+
public partial class StreamingResponseImageGenerationCallGeneratingUpdate
6+
{
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace OpenAI.Responses;
2+
3+
// CUSTOM: Renamed.
4+
[CodeGenType("ResponseImageGenCallInProgressEvent")]
5+
public partial class StreamingResponseImageGenerationCallInProgressUpdate
6+
{
7+
}

0 commit comments

Comments
 (0)