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
4 changes: 2 additions & 2 deletions src/Custom/Assistants/FileSearchToolResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public IList<string> VectorStoreIds
public FileSearchToolResources()
{ }

private void SerializeNewVectorStores(Utf8JsonWriter writer)
=> writer.WriteObjectValue(NewVectorStores, new ModelReaderWriterOptions("J"));
private void SerializeNewVectorStores(Utf8JsonWriter writer, ModelReaderWriterOptions options)
=> writer.WriteObjectValue(NewVectorStores, options);
}

14 changes: 7 additions & 7 deletions src/Custom/Assistants/GeneratorStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
[CodeGenModel("AssistantToolsCode")]
public partial class CodeInterpreterToolDefinition : ToolDefinition { }

[CodeGenModel("ThreadMessageStatus")]
[CodeGenModel("MessageObjectStatus")]
public readonly partial struct MessageStatus { }

[CodeGenModel("MessageObjectIncompleteDetails")]
public partial class MessageFailureDetails { }

[CodeGenModel("MessageFailureDetailsReason")]
[CodeGenModel("MessageObjectIncompleteDetailsReason")]
public readonly partial struct MessageFailureReason { }

[CodeGenModel("RunCompletionUsage")]
Expand All @@ -23,25 +23,25 @@ public partial class RunTokenUsage { }
[CodeGenModel("RunObjectLastError")]
public partial class RunError { }

[CodeGenModel("RunErrorCode")]
[CodeGenModel("RunObjectLastErrorCode")]
public readonly partial struct RunErrorCode { }

[CodeGenModel("RunObjectIncompleteDetails")]
public partial class RunIncompleteDetails { }

[CodeGenModel("RunIncompleteDetailsReason")]
[CodeGenModel("RunObjectIncompleteDetailsReason")]
public readonly partial struct RunIncompleteReason { }

[CodeGenModel("RunStepType")]
[CodeGenModel("RunStepObjectType")]
public readonly partial struct RunStepType { }

[CodeGenModel("RunStepStatus")]
[CodeGenModel("RunStepObjectStatus")]
public readonly partial struct RunStepStatus { }

[CodeGenModel("RunStepObjectLastError")]
public partial class RunStepError { }

[CodeGenModel("RunStepErrorCode")]
[CodeGenModel("RunStepObjectLastErrorCode")]
public readonly partial struct RunStepErrorCode { }

[CodeGenModel("RunStepCompletionUsage")]
Expand Down
34 changes: 20 additions & 14 deletions src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ internal partial class MessageDeltaContentImageUrlObjectImageUrl
}

[CodeGenModel("MessageDeltaContentImageFileObject")]
internal partial class MessageDeltaContentImageFileObject { private readonly new string Type; }
internal partial class MessageDeltaContentImageFileObject { }

[CodeGenModel("MessageDeltaContentImageUrlObject")]
internal partial class MessageDeltaContentImageUrlObject { private readonly new string Type; }
internal partial class MessageDeltaContentImageUrlObject { }

[CodeGenModel("MessageDeltaObjectDelta")]
internal partial class MessageDeltaObjectDelta
Expand Down Expand Up @@ -207,8 +207,8 @@ internal readonly partial struct InternalListRunStepsResponseObject {}
[CodeGenModel("RunStepDetailsToolCallsFileSearchObject")]
internal partial class InternalRunStepFileSearchToolCallDetails { }

[CodeGenModel("RunTruncationStrategyType")]
internal readonly partial struct InternalRunTruncationStrategyType { }
[CodeGenModel("TruncationObjectType")]
internal readonly partial struct InternalTruncationObjectType { }

[CodeGenModel("AssistantsNamedToolChoiceType")]
internal readonly partial struct InternalAssistantsNamedToolChoiceType { }
Expand Down Expand Up @@ -268,15 +268,12 @@ internal partial class InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFun
[CodeGenModel("AssistantsApiResponseFormat")]
internal partial class InternalAssistantsApiResponseFormat { }

[CodeGenModel("InternalAssistantsApiResponseFormatType")]
[CodeGenModel("AssistantsApiResponseFormatType")]
internal readonly partial struct InternalAssistantsApiResponseFormatType { }

[CodeGenModel("AssistantsNamedToolChoiceFunction")]
internal partial class InternalAssistantsNamedToolChoiceFunction { }

[CodeGenModel("ToolConstraintType")]
internal readonly partial struct InternalToolConstraintType { }

[CodeGenModel("AssistantObjectObject")]
internal readonly partial struct InternalAssistantObjectObject { }

Expand All @@ -295,11 +292,11 @@ internal readonly partial struct InternalThreadObjectObject { }
[CodeGenModel("MessageRequestContentTextObjectType")]
internal readonly partial struct InternalMessageRequestContentTextObjectType { }

[CodeGenModel("InternalMessageContentImageUrlObjectImageUrlDetail")]
[CodeGenModel("MessageContentImageUrlObjectImageUrlDetail")]
internal readonly partial struct InternalMessageContentImageUrlObjectImageUrlDetail { }

[CodeGenModel("InternalMessageContentItemFileObjectImageFileDetail")]
internal readonly partial struct InternalMessageContentItemFileObjectImageFileDetail { }
[CodeGenModel("MessageContentImageFileObjectImageFileDetail")]
internal readonly partial struct InternalMessageContentImageFileObjectImageFileDetail { }

[CodeGenModel("MessageDeltaContentImageFileObjectImageFileDetail")]
internal readonly partial struct InternalMessageDeltaContentImageFileObjectImageFileDetail { }
Expand Down Expand Up @@ -337,15 +334,18 @@ internal readonly partial struct InternalRunStepDeltaObjectObject { }
[CodeGenModel("RunToolCallObjectType")]
internal readonly partial struct InternalRunToolCallObjectType { }

[CodeGenModel("ThreadMessageRole")]
internal readonly partial struct InternalThreadMessageRole { }
[CodeGenModel("MessageObjectRole")]
internal readonly partial struct InternalMessageObjectRole { }

[CodeGenModel("CreateRunRequestModel")]
internal readonly partial struct InternalCreateRunRequestModel { }

[CodeGenModel("CreateThreadAndRunRequestModel")]
internal readonly partial struct InternalCreateThreadAndRunRequestModel { }

[CodeGenModel("CreateAssistantRequestResponseFormat")]
internal readonly partial struct InternalCreateAssistantRequestResponseFormat { }

[CodeGenModel("CreateAssistantRequestToolResources")]
internal partial class InternalCreateAssistantRequestToolResources { }

Expand All @@ -361,6 +361,9 @@ internal partial class InternalCreateAssistantRequestToolResourcesFileSearchVect
[CodeGenModel("CreateAssistantRequestToolResourcesFileSearchVectorStoreIdReferences")]
internal partial class InternalCreateAssistantRequestToolResourcesFileSearchVectorStoreIdReferences { }

[CodeGenModel("CreateThreadAndRunRequestToolChoice")]
internal readonly partial struct InternalCreateThreadAndRunRequestToolChoice { }

[CodeGenModel("CreateThreadAndRunRequestToolResources")]
internal partial class InternalCreateThreadAndRunRequestToolResources { }

Expand Down Expand Up @@ -416,4 +419,7 @@ internal partial class InternalThreadObjectToolResourcesCodeInterpreter { }
internal partial class InternalThreadObjectToolResourcesFileSearch { }

[CodeGenModel("AssistantToolsFileSearchTypeOnly")]
internal readonly partial struct InternalAssistantToolsFileSearchTypeOnly { }
internal partial class InternalAssistantToolsFileSearchTypeOnly { }

[CodeGenModel("AssistantToolsFileSearchTypeOnlyType")]
internal readonly partial struct InternalAssistantToolsFileSearchTypeOnlyType { }
5 changes: 3 additions & 2 deletions src/Custom/Assistants/MessageCreationAttachment.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.ClientModel.Primitives;
using System.Collections.Generic;
using System.Text.Json;

Expand All @@ -22,8 +23,8 @@ public partial class MessageCreationAttachment
[CodeGenMember("Tools")]
public IReadOnlyList<ToolDefinition> Tools { get; } = new ChangeTrackingList<ToolDefinition>();

private void SerializeTools(Utf8JsonWriter writer)
=> writer.WriteObjectValue(Tools);
private void SerializeTools(Utf8JsonWriter writer, ModelReaderWriterOptions options)
=> writer.WriteObjectValue(Tools, options);

private static void DeserializeTools(JsonProperty property, ref IReadOnlyList<ToolDefinition> tools)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Custom/Assistants/MessageRole.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace OpenAI.Assistants;

[CodeGenModel("MessageCreationOptionsRole")]
[CodeGenModel("CreateMessageRequestRole")]
public enum MessageRole
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Custom/Assistants/RunCreationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ private set
public RunCreationOptions()
{ }

private void SerializeToolConstraint(Utf8JsonWriter writer)
=> writer.WriteObjectValue(ToolConstraint, new ModelReaderWriterOptions("J"));
private void SerializeToolConstraint(Utf8JsonWriter writer, ModelReaderWriterOptions options)
=> writer.WriteObjectValue(ToolConstraint, options);
}
2 changes: 1 addition & 1 deletion src/Custom/Assistants/RunStatus.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace OpenAI.Assistants;

[CodeGenModel("ThreadRunStatus")]
[CodeGenModel("RunObjectStatus")]
public readonly partial struct RunStatus
{
/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions src/Custom/Assistants/RunTruncationStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OpenAI.Assistants
{
/// <summary> Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. </summary>
[CodeGenModel("TruncationObject")]
[CodeGenSuppress(nameof(RunTruncationStrategy), typeof(InternalRunTruncationStrategyType))]
[CodeGenSuppress(nameof(RunTruncationStrategy), typeof(InternalTruncationObjectType))]
public partial class RunTruncationStrategy
{
/// <summary>
Expand Down Expand Up @@ -42,7 +42,7 @@ public partial class RunTruncationStrategy

/// <summary> The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. </summary>
[CodeGenMember("Type")]
internal readonly InternalRunTruncationStrategyType _type;
internal readonly InternalTruncationObjectType _type;

/// <summary> The number of most recent messages from the thread when constructing the context for the run. </summary>
/// <remarks>
Expand All @@ -54,7 +54,7 @@ public partial class RunTruncationStrategy
/// The default <see cref="RunTruncationStrategy"/> that will eliminate messages in the middle of the thread
/// to fit within the context length of the model or the max prompt tokens.
/// </summary>
public static RunTruncationStrategy Auto { get; } = new(InternalRunTruncationStrategyType.Auto, 0, null);
public static RunTruncationStrategy Auto { get; } = new(InternalTruncationObjectType.Auto, 0, null);

/// <summary>
/// Creates a new <see cref="RunTruncationStrategy"/> instance using the <c>last_messages</c> strategy type,
Expand All @@ -63,6 +63,6 @@ public partial class RunTruncationStrategy
/// <param name="lastMessageCount"> The count of last messages that the run should evaluate. </param>
/// <returns></returns>
public static RunTruncationStrategy CreateLastMessagesStrategy(int lastMessageCount)
=> new(InternalRunTruncationStrategyType.LastMessages, lastMessageCount, null);
=> new(InternalTruncationObjectType.LastMessages, lastMessageCount, null);
}
}
39 changes: 39 additions & 0 deletions src/Custom/Assistants/ThreadRun.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace OpenAI.Assistants;

Expand All @@ -18,6 +20,43 @@ public partial class ThreadRun
[CodeGenMember("RequiredAction")]
internal readonly InternalRunRequiredAction _internalRequiredAction;

// CUSTOM: Removed null check for `toolConstraint` and `responseFormat`.
internal ThreadRun(string id, DateTimeOffset createdAt, string threadId, string assistantId, RunStatus status, InternalRunRequiredAction internalRequiredAction, RunError lastError, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, RunIncompleteDetails incompleteDetails, string model, string instructions, IEnumerable<ToolDefinition> tools, IReadOnlyDictionary<string, string> metadata, RunTokenUsage usage, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, bool? parallelToolCallsEnabled, AssistantResponseFormat responseFormat)
{
Argument.AssertNotNull(id, nameof(id));
Argument.AssertNotNull(threadId, nameof(threadId));
Argument.AssertNotNull(assistantId, nameof(assistantId));
Argument.AssertNotNull(model, nameof(model));
Argument.AssertNotNull(instructions, nameof(instructions));
Argument.AssertNotNull(tools, nameof(tools));

Id = id;
CreatedAt = createdAt;
ThreadId = threadId;
AssistantId = assistantId;
Status = status;
_internalRequiredAction = internalRequiredAction;
LastError = lastError;
ExpiresAt = expiresAt;
StartedAt = startedAt;
CancelledAt = cancelledAt;
FailedAt = failedAt;
CompletedAt = completedAt;
IncompleteDetails = incompleteDetails;
Model = model;
Instructions = instructions;
Tools = tools.ToList();
Metadata = metadata;
Usage = usage;
MaxPromptTokens = maxPromptTokens;
MaxCompletionTokens = maxCompletionTokens;
TruncationStrategy = truncationStrategy;
ToolConstraint = toolConstraint;
ParallelToolCallsEnabled = parallelToolCallsEnabled;
ResponseFormat = responseFormat;
}


/// <summary>
/// The list of required actions that must have their results submitted for the run to continue.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Custom/Assistants/ToolResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public partial class ToolResources
public ToolResources()
{}

private void SerializeFileSearch(Utf8JsonWriter writer)
=> writer.WriteObjectValue(FileSearch, new ModelReaderWriterOptions("J"));
private void SerializeFileSearch(Utf8JsonWriter writer, ModelReaderWriterOptions options)
=> writer.WriteObjectValue(FileSearch, options);
}
2 changes: 1 addition & 1 deletion src/Custom/Audio/AudioTranscriptionFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OpenAI.Audio;
/// <summary>
/// Specifies the format of the audio transcription.
/// </summary>
[CodeGenModel("AudioTranscriptionOptionsResponseFormat")]
[CodeGenModel("CreateTranscriptionRequestResponseFormat")]
public enum AudioTranscriptionFormat
{
/// <summary> Text. </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Custom/Audio/AudioTranslationFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OpenAI.Audio;
/// <summary>
/// Specifies the format of the audio translation.
/// </summary>
[CodeGenModel("AudioTranslationOptionsResponseFormat")]
[CodeGenModel("CreateTranslationRequestResponseFormat")]
public enum AudioTranslationFormat
{
/// <summary> Text. </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Custom/Audio/GeneratedSpeechFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace OpenAI.Audio;
/// <summary>
/// Represents an audio data format available as either input or output into an audio operation.
/// </summary>
[CodeGenModel("SpeechGenerationOptionsResponseFormat")]
[CodeGenModel("CreateSpeechRequestResponseFormat")]
public enum GeneratedSpeechFormat
{
/// <summary> MP3. /// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Custom/Audio/GeneratedSpeechVoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OpenAI.Audio;
/// <summary>
/// Represents the available text-to-speech voices.
/// </summary>
[CodeGenModel("SpeechGenerationOptionsVoice")]
[CodeGenModel("CreateSpeechRequestVoice")]
public enum GeneratedSpeechVoice
{
/// <summary> Alloy. </summary>
Expand Down
3 changes: 3 additions & 0 deletions src/Custom/Audio/Internal/GeneratorStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ internal readonly partial struct InternalCreateSpeechRequestModel { }
[CodeGenModel("CreateTranscriptionRequestModel")]
internal readonly partial struct InternalCreateTranscriptionRequestModel { }

[CodeGenModel("CreateTranscriptionRequestTimestampGranularity")]
internal readonly partial struct InternalCreateTranscriptionRequestTimestampGranularity { }

[CodeGenModel("CreateTranscriptionResponseJson")]
internal partial class InternalCreateTranscriptionResponseJson { }

Expand Down
4 changes: 2 additions & 2 deletions src/Custom/Batch/BatchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace OpenAI.Batch;

[CodeGenClient("Batches")]
[CodeGenSuppress("BatchClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))]
[CodeGenSuppress("CreateBatch", typeof(string), typeof(InternalBatchOperationEndpoint), typeof(InternalBatchCompletionTimeframe), typeof(IDictionary<string, string>))]
[CodeGenSuppress("CreateBatchAsync", typeof(string), typeof(InternalBatchOperationEndpoint), typeof(InternalBatchCompletionTimeframe), typeof(IDictionary<string, string>))]
[CodeGenSuppress("CreateBatch", typeof(string), typeof(InternalCreateBatchRequestEndpoint), typeof(InternalBatchCompletionTimeframe), typeof(IDictionary<string, string>))]
[CodeGenSuppress("CreateBatchAsync", typeof(string), typeof(InternalCreateBatchRequestEndpoint), typeof(InternalBatchCompletionTimeframe), typeof(IDictionary<string, string>))]
[CodeGenSuppress("RetrieveBatch", typeof(string))]
[CodeGenSuppress("RetrieveBatchAsync", typeof(string))]
[CodeGenSuppress("RetrieveBatch", typeof(string), typeof(RequestOptions))]
Expand Down
12 changes: 6 additions & 6 deletions src/Custom/Batch/Internal/GeneratorStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@ internal readonly partial struct InternalBatchErrorsObject { }
[CodeGenModel("Batch")]
internal partial class InternalBatchJob { }

[CodeGenModel("InternalBatchJobStatus")]
internal readonly partial struct InternalBatchJobStatus {}

[CodeGenModel("BatchObject")]
internal readonly partial struct InternalBatchObject { }

[CodeGenModel("InternalCreateBatchRequestEndpoint")]
internal readonly partial struct InternalBatchOperationEndpoint { }

[CodeGenModel("BatchRequestCounts")]
internal partial class InternalBatchRequestCounts { }

Expand All @@ -44,9 +38,15 @@ internal partial class InternalBatchRequestOutputError { }
[CodeGenModel("BatchRequestOutputResponse")]
internal partial class InternalBatchRequestOutputResponse { }

[CodeGenModel("BatchStatus")]
internal readonly partial struct InternalBatchStatus { }

[CodeGenModel("CreateBatchRequest")]
internal partial class InternalCreateBatchRequest { }

[CodeGenModel("CreateBatchRequestEndpoint")]
internal readonly partial struct InternalCreateBatchRequestEndpoint { }

[CodeGenModel("ListBatchesResponse")]
internal partial class InternalListBatchesResponse { }

Expand Down
Loading