Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions api/OpenAI.net10.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5026,6 +5026,8 @@ public class CodeInterpreterToolContainer : IJsonModel<CodeInterpreterToolContai
public ref JsonPatch Patch { get; }
protected virtual CodeInterpreterToolContainer JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
public static implicit operator CodeInterpreterToolContainer(CodeInterpreterToolContainerConfiguration containerConfiguration);
public static implicit operator CodeInterpreterToolContainer(string containerId);
protected virtual CodeInterpreterToolContainer PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
Expand Down
2 changes: 2 additions & 0 deletions api/OpenAI.net8.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5026,6 +5026,8 @@ public class CodeInterpreterToolContainer : IJsonModel<CodeInterpreterToolContai
public ref JsonPatch Patch { get; }
protected virtual CodeInterpreterToolContainer JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
public static implicit operator CodeInterpreterToolContainer(CodeInterpreterToolContainerConfiguration containerConfiguration);
public static implicit operator CodeInterpreterToolContainer(string containerId);
protected virtual CodeInterpreterToolContainer PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
Expand Down
2 changes: 2 additions & 0 deletions api/OpenAI.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4381,6 +4381,8 @@ public class CodeInterpreterToolContainer : IJsonModel<CodeInterpreterToolContai
public ref JsonPatch Patch { get; }
protected virtual CodeInterpreterToolContainer JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
public static implicit operator CodeInterpreterToolContainer(CodeInterpreterToolContainerConfiguration containerConfiguration);
public static implicit operator CodeInterpreterToolContainer(string containerId);
protected virtual CodeInterpreterToolContainer PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/Responses/Example10_CodeInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Example10_CodeInterpreter()
ResponseItem.CreateUserMessageItem("Create an Excel spreadsheet that contains the mathematical times tables from 1-12 and make it available for download."),
];

CodeInterpreterToolContainer container = new(CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration());
CodeInterpreterToolContainer container = CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration(); // An implicit conversion is used here for convenience.
CodeInterpreterTool codeInterpreterTool = new(container);

CreateResponseOptions options = new(inputItems)
Expand Down
2 changes: 1 addition & 1 deletion examples/Responses/Example10_CodeInterpreterAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task Example10_CodeInterpreterAsync()
ResponseItem.CreateUserMessageItem("Create an Excel spreadsheet that contains the mathematical times tables from 1-12 and make it available for download."),
];

CodeInterpreterToolContainer container = new(CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration());
CodeInterpreterToolContainer container = CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration(); // An implicit conversion is used here for convenience.
CodeInterpreterTool codeInterpreterTool = new(container);

CreateResponseOptions options = new(inputItems)
Expand Down
16 changes: 11 additions & 5 deletions src/Custom/Responses/Tools/CodeInterpreterToolContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ namespace OpenAI.Responses;
/// Represents a container for the code interpreter tool.
/// </summary>
[CodeGenType("DotNetCodeInterpreterToolContainer")]
[CodeGenVisibility(nameof(CodeInterpreterToolContainer), CodeGenVisibility.Internal)]
public partial class CodeInterpreterToolContainer
{
// CUSTOM: Made internal.
internal CodeInterpreterToolContainer()
{
}

// CUSTOM: Added to support the corresponding component of the union.
/// <summary>
/// Initializes a new instance of the <see cref="CodeInterpreterContainer"/> class.
/// </summary>
/// <param name="containerId">The ID of the container.</param>
public CodeInterpreterToolContainer(string containerId)
{
Argument.AssertNotNull(containerId, nameof(containerId));

ContainerId = containerId;
}

Expand All @@ -33,6 +31,8 @@ public CodeInterpreterToolContainer(string containerId)
/// <param name="containerConfiguration">The configuration of the container.</param>
public CodeInterpreterToolContainer(CodeInterpreterToolContainerConfiguration containerConfiguration)
{
Argument.AssertNotNull(containerConfiguration, nameof(containerConfiguration));

ContainerConfiguration = containerConfiguration;
}

Expand All @@ -45,4 +45,10 @@ public CodeInterpreterToolContainer(CodeInterpreterToolContainerConfiguration co
// - Removed setter.
[CodeGenMember("Container")]
public CodeInterpreterToolContainerConfiguration ContainerConfiguration { get; }

// CUSTOM: Added for convenience.
public static implicit operator CodeInterpreterToolContainer(string containerId) => containerId is null ? null : new(containerId);

// CUSTOM: Added for convenience.
public static implicit operator CodeInterpreterToolContainer(CodeInterpreterToolContainerConfiguration containerConfiguration) => containerConfiguration is null ? null : new(containerConfiguration);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public McpToolCallApprovalPolicy(CustomMcpToolCallApprovalPolicy customPolicy)
public CustomMcpToolCallApprovalPolicy CustomPolicy { get; }

// CUSTOM: Added for convenience.
public static implicit operator McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy globalPolicy) => new(globalPolicy);
public static implicit operator McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy globalPolicy) => globalPolicy == default ? null : new(globalPolicy);

// CUSTOM: Added for convenience.
public static implicit operator McpToolCallApprovalPolicy(CustomMcpToolCallApprovalPolicy customPolicy) => new(customPolicy);
public static implicit operator McpToolCallApprovalPolicy(CustomMcpToolCallApprovalPolicy customPolicy) => customPolicy is null ? null : new(customPolicy);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public partial class CodeInterpreterToolContainer
[Experimental("SCME0001")]
private JsonPatch _patch;

internal CodeInterpreterToolContainer()
{
}

#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
internal CodeInterpreterToolContainer(string containerId, CodeInterpreterToolContainerConfiguration containerConfiguration, in JsonPatch patch)
{
Expand Down
6 changes: 2 additions & 4 deletions tests/Responses/ResponsesSmokeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ public void SerializeCodeInterpreterToolContainerAsString(bool fromRawJson)
else
{
// We construct a new instance. Later, we serialize it and confirm it was constructed correctly.
container = new CodeInterpreterToolContainer(containerId);
container = containerId;
}

BinaryData serializedContainer = ModelReaderWriter.Write(container);
Expand Down Expand Up @@ -542,12 +542,10 @@ public void SerializeCodeInterpreterToolContainerAsObject(bool fromRawJson)
else
{
// We construct a new instance. Later, we serialize it and confirm it was constructed correctly.
AutomaticCodeInterpreterToolContainerConfiguration autoConfig = new()
container = new AutomaticCodeInterpreterToolContainerConfiguration()
{
FileIds = { fileId }
};

container = new CodeInterpreterToolContainer(autoConfig);
}

BinaryData serializedContainer = ModelReaderWriter.Write(container);
Expand Down