Skip to content

Commit 0fd66a5

Browse files
committed
wip
1 parent 62e5fbd commit 0fd66a5

10 files changed

+59
-61
lines changed

src/Custom/Responses/GeneratorStubs.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace OpenAI.Responses;
33
[CodeGenType("CodeInterpreterToolImageOutput")] public partial class CodeInterpreterToolImageOutput {}
44
[CodeGenType("CodeInterpreterToolLogsOutput")] public partial class CodeInterpreterToolLogsOutput {}
55
[CodeGenType("CodeInterpreterToolOutput")] public partial class CodeInterpreterToolOutput {}
6-
[CodeGenType("CodeInterpreterToolAuto")] public partial class CodeInterpreterToolAuto {}
6+
[CodeGenType("CodeInterpreterToolAuto")] public partial class AutomaticCodeInterpreterContainerConfiguration {}
77
[CodeGenType("CodeInterpreterContainerConfiguration")] public partial class CodeInterpreterContainerConfiguration {}
88
[CodeGenType("CodeInterpreterContainerConfigurationType")] readonly partial struct CodeInterpreterContainerConfigurationType {}
9+

src/Custom/Responses/Tools/AutomaticCodeInterpreterContainerConfiguration.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ namespace OpenAI.Responses;
55
/// <summary>
66
/// Represents a configuration for an automatic Code Interpreter container.
77
/// </summary>
8-
public partial class CodeInterpreterToolAuto : CodeInterpreterContainerConfiguration
8+
public partial class AutomaticCodeInterpreterContainerConfiguration : CodeInterpreterContainerConfiguration
99
{
1010

1111
/// <summary>
1212
/// Initializes a new instance of the <see cref="CodeInterpreterToolAuto"/> class.
1313
/// </summary>
1414
/// <param name="fileIds"></param>
15-
public CodeInterpreterToolAuto(IEnumerable<string> fileIds = null)
15+
public AutomaticCodeInterpreterContainerConfiguration(IEnumerable<string> fileIds = null)
1616
{
1717
if (fileIds != null)
1818
{
@@ -23,9 +23,4 @@ public CodeInterpreterToolAuto(IEnumerable<string> fileIds = null)
2323
FileIds = new List<string>();
2424
}
2525
}
26-
27-
/// <summary>
28-
/// Gets the list of file IDs associated with the container.
29-
/// </summary>
30-
public IList<string> FileIds { get; }
3126
}

src/Custom/Responses/Tools/CodeInterpreterContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal BinaryData AsBinaryData()
4040
{
4141
return this.ContainerId != null
4242
? new BinaryData($"\"{ContainerId}\"")
43-
: ContainerConfiguration is CodeInterpreterToolAuto autoConfig && autoConfig.FileIds?.Any() == true ?
43+
: ContainerConfiguration is AutomaticCodeInterpreterContainerConfiguration autoConfig && autoConfig.FileIds?.Any() == true ?
4444
new BinaryData($"{{\"type\": \"auto\", \"file_ids\": [{string.Join(", ", autoConfig.FileIds.Select(id => $"\"{id}\""))}]}}") :
4545
new BinaryData("{\"type\": \"auto\"}");
4646
}

src/Custom/Responses/Tools/CodeInterpreterContainerConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public partial class CodeInterpreterContainerConfiguration
1313
/// </summary>
1414
/// <param name="fileIds">The list of file IDs associated with the container.</param>
1515
/// <returns>A new instance of the <see cref="AutomaticCodeInterpreterContainerConfiguration"/> class.</returns>
16-
public static CodeInterpreterToolAuto CreateAutomaticConfiguration(IEnumerable<string> fileIds = null) =>
17-
new CodeInterpreterToolAuto(fileIds);
16+
public static AutomaticCodeInterpreterContainerConfiguration CreateAutomaticConfiguration(IEnumerable<string> fileIds = null) =>
17+
new AutomaticCodeInterpreterContainerConfiguration(fileIds);
1818
}

src/Generated/Models/OpenAIContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace OpenAI
3737
[ModelReaderWriterBuildable(typeof(AudioTranscriptionOptions))]
3838
[ModelReaderWriterBuildable(typeof(AudioTranslation))]
3939
[ModelReaderWriterBuildable(typeof(AudioTranslationOptions))]
40+
[ModelReaderWriterBuildable(typeof(AutomaticCodeInterpreterContainerConfiguration))]
4041
[ModelReaderWriterBuildable(typeof(ChatAudioOptions))]
4142
[ModelReaderWriterBuildable(typeof(ChatCompletion))]
4243
[ModelReaderWriterBuildable(typeof(ChatCompletionCollectionOptions))]
@@ -66,7 +67,6 @@ namespace OpenAI
6667
[ModelReaderWriterBuildable(typeof(CodeInterpreterCallResponseItem))]
6768
[ModelReaderWriterBuildable(typeof(CodeInterpreterContainerConfiguration))]
6869
[ModelReaderWriterBuildable(typeof(CodeInterpreterTool))]
69-
[ModelReaderWriterBuildable(typeof(CodeInterpreterToolAuto))]
7070
[ModelReaderWriterBuildable(typeof(CodeInterpreterToolDefinition))]
7171
[ModelReaderWriterBuildable(typeof(CodeInterpreterToolImageOutput))]
7272
[ModelReaderWriterBuildable(typeof(CodeInterpreterToolLogsOutput))]

src/Generated/Models/Responses/CodeInterpreterToolAuto.Serialization.cs renamed to src/Generated/Models/Responses/AutomaticCodeInterpreterContainerConfiguration.Serialization.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
namespace OpenAI.Responses
1212
{
13-
public partial class CodeInterpreterToolAuto : IJsonModel<CodeInterpreterToolAuto>
13+
public partial class AutomaticCodeInterpreterContainerConfiguration : IJsonModel<AutomaticCodeInterpreterContainerConfiguration>
1414
{
15-
void IJsonModel<CodeInterpreterToolAuto>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
15+
void IJsonModel<AutomaticCodeInterpreterContainerConfiguration>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
1616
{
1717
writer.WriteStartObject();
1818
JsonModelWriteCore(writer, options);
@@ -21,10 +21,10 @@ void IJsonModel<CodeInterpreterToolAuto>.Write(Utf8JsonWriter writer, ModelReade
2121

2222
protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
2323
{
24-
string format = options.Format == "W" ? ((IPersistableModel<CodeInterpreterToolAuto>)this).GetFormatFromOptions(options) : options.Format;
24+
string format = options.Format == "W" ? ((IPersistableModel<AutomaticCodeInterpreterContainerConfiguration>)this).GetFormatFromOptions(options) : options.Format;
2525
if (format != "J")
2626
{
27-
throw new FormatException($"The model {nameof(CodeInterpreterToolAuto)} does not support writing '{format}' format.");
27+
throw new FormatException($"The model {nameof(AutomaticCodeInterpreterContainerConfiguration)} does not support writing '{format}' format.");
2828
}
2929
base.JsonModelWriteCore(writer, options);
3030
if (Optional.IsCollectionDefined(FileIds) && _additionalBinaryDataProperties?.ContainsKey("file_ids") != true)
@@ -44,20 +44,20 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri
4444
}
4545
}
4646

47-
CodeInterpreterToolAuto IJsonModel<CodeInterpreterToolAuto>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (CodeInterpreterToolAuto)JsonModelCreateCore(ref reader, options);
47+
AutomaticCodeInterpreterContainerConfiguration IJsonModel<AutomaticCodeInterpreterContainerConfiguration>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AutomaticCodeInterpreterContainerConfiguration)JsonModelCreateCore(ref reader, options);
4848

4949
protected override CodeInterpreterContainerConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
5050
{
51-
string format = options.Format == "W" ? ((IPersistableModel<CodeInterpreterToolAuto>)this).GetFormatFromOptions(options) : options.Format;
51+
string format = options.Format == "W" ? ((IPersistableModel<AutomaticCodeInterpreterContainerConfiguration>)this).GetFormatFromOptions(options) : options.Format;
5252
if (format != "J")
5353
{
54-
throw new FormatException($"The model {nameof(CodeInterpreterToolAuto)} does not support reading '{format}' format.");
54+
throw new FormatException($"The model {nameof(AutomaticCodeInterpreterContainerConfiguration)} does not support reading '{format}' format.");
5555
}
5656
using JsonDocument document = JsonDocument.ParseValue(ref reader);
57-
return DeserializeCodeInterpreterToolAuto(document.RootElement, options);
57+
return DeserializeAutomaticCodeInterpreterContainerConfiguration(document.RootElement, options);
5858
}
5959

60-
internal static CodeInterpreterToolAuto DeserializeCodeInterpreterToolAuto(JsonElement element, ModelReaderWriterOptions options)
60+
internal static AutomaticCodeInterpreterContainerConfiguration DeserializeAutomaticCodeInterpreterContainerConfiguration(JsonElement element, ModelReaderWriterOptions options)
6161
{
6262
if (element.ValueKind == JsonValueKind.Null)
6363
{
@@ -97,40 +97,40 @@ internal static CodeInterpreterToolAuto DeserializeCodeInterpreterToolAuto(JsonE
9797
// Plugin customization: remove options.Format != "W" check
9898
additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText()));
9999
}
100-
return new CodeInterpreterToolAuto(kind, additionalBinaryDataProperties, fileIds ?? new ChangeTrackingList<string>());
100+
return new AutomaticCodeInterpreterContainerConfiguration(kind, additionalBinaryDataProperties, fileIds ?? new ChangeTrackingList<string>());
101101
}
102102

103-
BinaryData IPersistableModel<CodeInterpreterToolAuto>.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
103+
BinaryData IPersistableModel<AutomaticCodeInterpreterContainerConfiguration>.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
104104

105105
protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options)
106106
{
107-
string format = options.Format == "W" ? ((IPersistableModel<CodeInterpreterToolAuto>)this).GetFormatFromOptions(options) : options.Format;
107+
string format = options.Format == "W" ? ((IPersistableModel<AutomaticCodeInterpreterContainerConfiguration>)this).GetFormatFromOptions(options) : options.Format;
108108
switch (format)
109109
{
110110
case "J":
111111
return ModelReaderWriter.Write(this, options, OpenAIContext.Default);
112112
default:
113-
throw new FormatException($"The model {nameof(CodeInterpreterToolAuto)} does not support writing '{options.Format}' format.");
113+
throw new FormatException($"The model {nameof(AutomaticCodeInterpreterContainerConfiguration)} does not support writing '{options.Format}' format.");
114114
}
115115
}
116116

117-
CodeInterpreterToolAuto IPersistableModel<CodeInterpreterToolAuto>.Create(BinaryData data, ModelReaderWriterOptions options) => (CodeInterpreterToolAuto)PersistableModelCreateCore(data, options);
117+
AutomaticCodeInterpreterContainerConfiguration IPersistableModel<AutomaticCodeInterpreterContainerConfiguration>.Create(BinaryData data, ModelReaderWriterOptions options) => (AutomaticCodeInterpreterContainerConfiguration)PersistableModelCreateCore(data, options);
118118

119119
protected override CodeInterpreterContainerConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options)
120120
{
121-
string format = options.Format == "W" ? ((IPersistableModel<CodeInterpreterToolAuto>)this).GetFormatFromOptions(options) : options.Format;
121+
string format = options.Format == "W" ? ((IPersistableModel<AutomaticCodeInterpreterContainerConfiguration>)this).GetFormatFromOptions(options) : options.Format;
122122
switch (format)
123123
{
124124
case "J":
125125
using (JsonDocument document = JsonDocument.Parse(data))
126126
{
127-
return DeserializeCodeInterpreterToolAuto(document.RootElement, options);
127+
return DeserializeAutomaticCodeInterpreterContainerConfiguration(document.RootElement, options);
128128
}
129129
default:
130-
throw new FormatException($"The model {nameof(CodeInterpreterToolAuto)} does not support reading '{options.Format}' format.");
130+
throw new FormatException($"The model {nameof(AutomaticCodeInterpreterContainerConfiguration)} does not support reading '{options.Format}' format.");
131131
}
132132
}
133133

134-
string IPersistableModel<CodeInterpreterToolAuto>.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
134+
string IPersistableModel<AutomaticCodeInterpreterContainerConfiguration>.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
135135
}
136136
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// <auto-generated/>
2+
3+
#nullable disable
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Diagnostics.CodeAnalysis;
8+
using OpenAI;
9+
10+
namespace OpenAI.Responses
11+
{
12+
[Experimental("OPENAI001")]
13+
public partial class AutomaticCodeInterpreterContainerConfiguration : CodeInterpreterContainerConfiguration
14+
{
15+
public AutomaticCodeInterpreterContainerConfiguration() : this(CodeInterpreterContainerConfigurationType.Auto, null, null)
16+
{
17+
}
18+
19+
internal AutomaticCodeInterpreterContainerConfiguration(CodeInterpreterContainerConfigurationType kind, IDictionary<string, BinaryData> additionalBinaryDataProperties, IList<string> fileIds) : base(kind, additionalBinaryDataProperties)
20+
{
21+
// Plugin customization: ensure initialization of collections
22+
FileIds = fileIds ?? new ChangeTrackingList<string>();
23+
}
24+
25+
public IList<string> FileIds { get; }
26+
}
27+
}

src/Generated/Models/Responses/CodeInterpreterContainerConfiguration.Serialization.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ internal static CodeInterpreterContainerConfiguration DeserializeCodeInterpreter
8181
switch (discriminator.GetString())
8282
{
8383
case "auto":
84-
return CodeInterpreterToolAuto.DeserializeCodeInterpreterToolAuto(element, options);
84+
return AutomaticCodeInterpreterContainerConfiguration.DeserializeAutomaticCodeInterpreterContainerConfiguration(element, options);
8585
}
8686
}
8787
return InternalUnknownCodeInterpreterContainerConfiguration.DeserializeInternalUnknownCodeInterpreterContainerConfiguration(element, options);

src/Generated/Models/Responses/CodeInterpreterToolAuto.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/Responses/ResponsesTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public async Task CodeInterpreterToolWithoutFileIds()
235235
{
236236
OpenAIResponseClient client = GetTestClient();
237237

238-
ResponseTool codeInterpreterTool = ResponseTool.CreateCodeInterpreterTool(new CodeInterpreterContainer(new CodeInterpreterToolAuto()));
238+
ResponseTool codeInterpreterTool = ResponseTool.CreateCodeInterpreterTool(new CodeInterpreterContainer(new AutomaticCodeInterpreterContainerConfiguration()));
239239
ResponseCreationOptions responseOptions = new()
240240
{
241241
Tools = { codeInterpreterTool },
@@ -266,7 +266,7 @@ public async Task CodeInterpreterToolWithEmptyFileIds()
266266
{
267267
OpenAIResponseClient client = GetTestClient();
268268

269-
ResponseTool codeInterpreterTool = ResponseTool.CreateCodeInterpreterTool(new(new CodeInterpreterToolAuto(new List<string>())));
269+
ResponseTool codeInterpreterTool = ResponseTool.CreateCodeInterpreterTool(new(new AutomaticCodeInterpreterContainerConfiguration(new List<string>())));
270270
ResponseCreationOptions responseOptions = new()
271271
{
272272
Tools = { codeInterpreterTool },
@@ -376,7 +376,7 @@ public async Task CodeInterpreterToolWithUploadedFileIds()
376376
fileIds.Add(pythonFile.Id);
377377

378378
// Create CodeInterpreter tool with uploaded file IDs
379-
ResponseTool codeInterpreterTool = ResponseTool.CreateCodeInterpreterTool(new(new CodeInterpreterToolAuto(fileIds)));
379+
ResponseTool codeInterpreterTool = ResponseTool.CreateCodeInterpreterTool(new(new AutomaticCodeInterpreterContainerConfiguration(fileIds)));
380380
ResponseCreationOptions responseOptions = new()
381381
{
382382
Tools = { codeInterpreterTool },
@@ -417,7 +417,7 @@ public async Task CodeInterpreterToolStreaming()
417417
{
418418
OpenAIResponseClient client = GetTestClient();
419419

420-
ResponseTool codeInterpreterTool = ResponseTool.CreateCodeInterpreterTool(new CodeInterpreterContainer(new CodeInterpreterToolAuto()));
420+
ResponseTool codeInterpreterTool = ResponseTool.CreateCodeInterpreterTool(new CodeInterpreterContainer(new AutomaticCodeInterpreterContainerConfiguration()));
421421
ResponseCreationOptions responseOptions = new()
422422
{
423423
Tools = { codeInterpreterTool },
@@ -466,7 +466,7 @@ public async Task CodeInterpreterToolStreamingWithFiles()
466466
fileIds.Add(csvFile.Id);
467467

468468
// Create CodeInterpreter tool with uploaded file IDs
469-
ResponseTool codeInterpreterTool = ResponseTool.CreateCodeInterpreterTool(new CodeInterpreterContainer(new CodeInterpreterToolAuto(fileIds)));
469+
ResponseTool codeInterpreterTool = ResponseTool.CreateCodeInterpreterTool(new CodeInterpreterContainer(new AutomaticCodeInterpreterContainerConfiguration(fileIds)));
470470
ResponseCreationOptions responseOptions = new()
471471
{
472472
Tools = { codeInterpreterTool },

0 commit comments

Comments
 (0)