Skip to content
Open
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
2 changes: 1 addition & 1 deletion codegen/generator/src/OpenAI.Library.Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20251003.1" />
<PackageReference Include="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20251009.7" />
</ItemGroup>

<!-- Copy output to package dist path for local execution and -->
Expand Down
4 changes: 2 additions & 2 deletions codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
],
"dependencies": {
"@open-ai/plugin": "file:",
"@azure-tools/typespec-client-generator-core": "0.60.0",
"@typespec/http-client-csharp": "1.0.0-alpha.20251003.1",
"@azure-tools/typespec-client-generator-core": "0.60.3",
"@typespec/http-client-csharp": "1.0.0-alpha.20251009.7",
"@typespec/http": "1.4.0",
"@typespec/openapi": "1.4.0"
},
Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/Generated/BatchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using System;
using System.ClientModel;
using System.ClientModel.Primitives;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using OpenAI;

Expand All @@ -22,6 +24,24 @@ protected BatchClient()

public ClientPipeline Pipeline { get; }

public virtual ClientResult<InternalBatchJob> CreateBatch(string inputFileId, InternalCreateBatchRequestEndpoint endpoint, IDictionary<string, string> metadata = default, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(inputFileId, nameof(inputFileId));

InternalCreateBatchRequest spreadModel = new InternalCreateBatchRequest(default, endpoint, "24h", metadata, default);
ClientResult result = this.CreateBatch(spreadModel, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
return ClientResult.FromValue((InternalBatchJob)result, result.GetRawResponse());
}

public virtual async Task<ClientResult<InternalBatchJob>> CreateBatchAsync(string inputFileId, InternalCreateBatchRequestEndpoint endpoint, IDictionary<string, string> metadata = default, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(inputFileId, nameof(inputFileId));

InternalCreateBatchRequest spreadModel = new InternalCreateBatchRequest(default, endpoint, "24h", metadata, default);
ClientResult result = await this.CreateBatchAsync(spreadModel, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false);
return ClientResult.FromValue((InternalBatchJob)result, result.GetRawResponse());
}

public virtual ClientResult GetBatch(string batchId, RequestOptions options)
{
Argument.AssertNotNullOrEmpty(batchId, nameof(batchId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ public partial class RunStepFileSearchResultContent
{
private protected IDictionary<string, BinaryData> _additionalBinaryDataProperties;

internal RunStepFileSearchResultContent(RunStepFileSearchResultContentKind kind, string text)
internal RunStepFileSearchResultContent(string text)
{
Kind = kind;
Text = text;
}

Expand Down
10 changes: 7 additions & 3 deletions src/Generated/Models/Batch/InternalBatchErrors.Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
if (Optional.IsDefined(Object) && _additionalBinaryDataProperties?.ContainsKey("object") != true)
{
writer.WritePropertyName("object"u8);
writer.WriteStringValue(Object);
writer.WriteStringValue(Object.Value.ToString());
}
if (Optional.IsCollectionDefined(Data) && _additionalBinaryDataProperties?.ContainsKey("data") != true)
{
Expand Down Expand Up @@ -82,14 +82,18 @@ internal static InternalBatchErrors DeserializeInternalBatchErrors(JsonElement e
{
return null;
}
string @object = default;
InternalBatchErrorsObject? @object = default;
IList<InternalBatchError> data = default;
IDictionary<string, BinaryData> additionalBinaryDataProperties = new ChangeTrackingDictionary<string, BinaryData>();
foreach (var prop in element.EnumerateObject())
{
if (prop.NameEquals("object"u8))
{
@object = prop.Value.GetString();
if (prop.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
@object = new InternalBatchErrorsObject(prop.Value.GetString());
continue;
}
if (prop.NameEquals("data"u8))
Expand Down
6 changes: 3 additions & 3 deletions src/Generated/Models/Batch/InternalBatchErrors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ internal partial class InternalBatchErrors
{
private protected IDictionary<string, BinaryData> _additionalBinaryDataProperties;

internal InternalBatchErrors() : this(null, null, null)
internal InternalBatchErrors() : this(default, null, null)
{
}

internal InternalBatchErrors(string @object, IList<InternalBatchError> data, IDictionary<string, BinaryData> additionalBinaryDataProperties)
internal InternalBatchErrors(InternalBatchErrorsObject? @object, IList<InternalBatchError> data, IDictionary<string, BinaryData> additionalBinaryDataProperties)
{
// Plugin customization: ensure initialization of collections
Object = @object;
Data = data ?? new ChangeTrackingList<InternalBatchError>();
_additionalBinaryDataProperties = additionalBinaryDataProperties;
}

public string Object { get; }
internal InternalBatchErrorsObject? Object { get; }

internal IList<InternalBatchError> Data { get; }

Expand Down
43 changes: 43 additions & 0 deletions src/Generated/Models/Batch/InternalBatchErrorsObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// <auto-generated/>

#nullable disable

using System;
using System.ComponentModel;
using OpenAI;

namespace OpenAI.Batch
{
internal readonly partial struct InternalBatchErrorsObject : IEquatable<InternalBatchErrorsObject>
{
private readonly string _value;
private const string ListValue = "list";

public InternalBatchErrorsObject(string value)
{
Argument.AssertNotNull(value, nameof(value));

_value = value;
}

internal static InternalBatchErrorsObject List { get; } = new InternalBatchErrorsObject(ListValue);

public static bool operator ==(InternalBatchErrorsObject left, InternalBatchErrorsObject right) => left.Equals(right);

public static bool operator !=(InternalBatchErrorsObject left, InternalBatchErrorsObject right) => !left.Equals(right);

public static implicit operator InternalBatchErrorsObject(string value) => new InternalBatchErrorsObject(value);

public static implicit operator InternalBatchErrorsObject?(string value) => value == null ? null : new InternalBatchErrorsObject(value);

[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj) => obj is InternalBatchErrorsObject other && Equals(other);

public bool Equals(InternalBatchErrorsObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;

public override string ToString() => _value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
if (Optional.IsDefined(Method) && _additionalBinaryDataProperties?.ContainsKey("method") != true)
{
writer.WritePropertyName("method"u8);
writer.WriteStringValue(Method);
writer.WriteStringValue(Method.Value.ToString());
}
if (Optional.IsDefined(Url) && _additionalBinaryDataProperties?.ContainsKey("url") != true)
{
Expand Down Expand Up @@ -83,7 +83,7 @@ internal static InternalBatchRequestInput DeserializeInternalBatchRequestInput(J
return null;
}
string customId = default;
string @method = default;
InternalBatchRequestInputMethod? @method = default;
Uri url = default;
IDictionary<string, BinaryData> additionalBinaryDataProperties = new ChangeTrackingDictionary<string, BinaryData>();
foreach (var prop in element.EnumerateObject())
Expand All @@ -95,7 +95,11 @@ internal static InternalBatchRequestInput DeserializeInternalBatchRequestInput(J
}
if (prop.NameEquals("method"u8))
{
@method = prop.Value.GetString();
if (prop.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
@method = new InternalBatchRequestInputMethod(prop.Value.GetString());
continue;
}
if (prop.NameEquals("url"u8))
Expand Down
4 changes: 2 additions & 2 deletions src/Generated/Models/Batch/InternalBatchRequestInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public InternalBatchRequestInput()
{
}

internal InternalBatchRequestInput(string customId, string @method, Uri url, IDictionary<string, BinaryData> additionalBinaryDataProperties)
internal InternalBatchRequestInput(string customId, InternalBatchRequestInputMethod? @method, Uri url, IDictionary<string, BinaryData> additionalBinaryDataProperties)
{
CustomId = customId;
Method = @method;
Expand All @@ -25,7 +25,7 @@ internal InternalBatchRequestInput(string customId, string @method, Uri url, IDi

public string CustomId { get; set; }

public string Method { get; set; }
internal InternalBatchRequestInputMethod? Method { get; set; }

public Uri Url { get; set; }

Expand Down
43 changes: 43 additions & 0 deletions src/Generated/Models/Batch/InternalBatchRequestInputMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// <auto-generated/>

#nullable disable

using System;
using System.ComponentModel;
using OpenAI;

namespace OpenAI.Batch
{
internal readonly partial struct InternalBatchRequestInputMethod : IEquatable<InternalBatchRequestInputMethod>
{
private readonly string _value;
private const string POSTValue = "POST";

public InternalBatchRequestInputMethod(string value)
{
Argument.AssertNotNull(value, nameof(value));

_value = value;
}

internal static InternalBatchRequestInputMethod POST { get; } = new InternalBatchRequestInputMethod(POSTValue);

public static bool operator ==(InternalBatchRequestInputMethod left, InternalBatchRequestInputMethod right) => left.Equals(right);

public static bool operator !=(InternalBatchRequestInputMethod left, InternalBatchRequestInputMethod right) => !left.Equals(right);

public static implicit operator InternalBatchRequestInputMethod(string value) => new InternalBatchRequestInputMethod(value);

public static implicit operator InternalBatchRequestInputMethod?(string value) => value == null ? null : new InternalBatchRequestInputMethod(value);

[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj) => obj is InternalBatchRequestInputMethod other && Equals(other);

public bool Equals(InternalBatchRequestInputMethod other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;

public override string ToString() => _value;
}
}
2 changes: 1 addition & 1 deletion src/Generated/Models/Batch/InternalCreateBatchRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal InternalCreateBatchRequest(string inputFileId, InternalCreateBatchReque

internal InternalCreateBatchRequestEndpoint Endpoint { get; }

public string CompletionWindow { get; } = "24h";
internal string CompletionWindow { get; } = "24h";

public IDictionary<string, string> Metadata { get; }

Expand Down
3 changes: 1 addition & 2 deletions src/Generated/Models/Chat/ChatCompletionMessageListDatum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ public partial class ChatCompletionMessageListDatum
{
private protected IDictionary<string, BinaryData> _additionalBinaryDataProperties;

internal ChatCompletionMessageListDatum(string content, string refusal, ChatMessageRole role, string id)
internal ChatCompletionMessageListDatum(string content, string refusal, string id)
{
Content = content;
Refusal = refusal;
ToolCalls = new ChangeTrackingList<ChatToolCall>();
Annotations = new ChangeTrackingList<ChatMessageAnnotation>();
Role = role;
Id = id;
}

Expand Down
8 changes: 0 additions & 8 deletions src/Generated/Models/Chat/ChatTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ public partial class ChatTool
{
private protected IDictionary<string, BinaryData> _additionalBinaryDataProperties;

internal ChatTool(ChatToolKind kind, InternalFunctionDefinition function)
{
Argument.AssertNotNull(function, nameof(function));

Kind = kind;
Function = function;
}

internal ChatTool(ChatToolKind kind, InternalFunctionDefinition function, IDictionary<string, BinaryData> additionalBinaryDataProperties)
{
Kind = kind;
Expand Down
Loading