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
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void Example01_RetrievalAugmentedGeneration()

// Finally, we'll print out the full history for the thread that includes the augmented generation
PageCollection<ThreadMessage> messagePages
= assistantClient.GetMessages(threadRun.ThreadId, new MessageCollectionOptions() { Order = ListOrder.OldestFirst });
= assistantClient.GetMessages(threadRun.ThreadId, new MessageCollectionOptions() { Order = ListOrder.OldestFirst });
IEnumerable<ThreadMessage> messages = messagePages.GetAllValues();

foreach (ThreadMessage message in messages)
Expand Down
7 changes: 4 additions & 3 deletions .dotnet/examples/Chat/Example01_SimpleChat_Cancellations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ public void Example01_SimpleChat_Cancellations()
RequestOptions options = new() { CancellationToken = ct.Token };

ChatMessage message = ChatMessage.CreateUserMessage("Say 'this is a test.'");
var body = new {
var body = new
{
model = "gpt-4o",
messages = new[] {
messages = new[] {
new
{
role = "user",
content = "Say \u0027this is a test.\u0027"
}
}
};

BinaryData json = BinaryData.FromObjectAsJson(body);
ClientResult result = client.CompleteChat(BinaryContent.Create(json), options);

Expand Down
2 changes: 1 addition & 1 deletion .dotnet/examples/Chat/Example07_StructuredOutputs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Example07_StructuredOutputs()
options);

using JsonDocument structuredJson = JsonDocument.Parse(chatCompletion.ToString());

Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer").GetString()}");
Console.WriteLine("Reasoning steps:");

Expand Down
2 changes: 1 addition & 1 deletion .dotnet/examples/Chat/Example07_StructuredOutputsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task Example07_StructuredOutputsAsync()
options);

using JsonDocument structuredJson = JsonDocument.Parse(chatCompletion.ToString());

Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer").GetString()}");
Console.WriteLine("Reasoning steps:");

Expand Down
11 changes: 6 additions & 5 deletions .dotnet/examples/Embeddings/Example04_SimpleEmbeddingProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ public void Example04_SimpleEmbeddingProtocol()
+ " and a really helpful concierge. The location is perfect -- right downtown, close to all the tourist"
+ " attractions. We highly recommend this hotel.";

BinaryData input = BinaryData.FromObjectAsJson(new {
model = "text-embedding-3-small",
input = description,
encoding_format = "float"
});
BinaryData input = BinaryData.FromObjectAsJson(new
{
model = "text-embedding-3-small",
input = description,
encoding_format = "float"
});

using BinaryContent content = BinaryContent.Create(input);
ClientResult result = client.GenerateEmbeddings(content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public virtual AsyncPageCollection<ThreadMessage> GetMessagesAsync(
/// page of values, call <see cref="PageCollection{T}.GetCurrentPage"/>.</remarks>
/// <returns> A collection of pages of <see cref="ThreadMessage"/>. </returns>
public virtual PageCollection<ThreadMessage> GetMessages(
AssistantThread thread,
AssistantThread thread,
MessageCollectionOptions options = default)
{
Argument.AssertNotNull(thread, nameof(thread));
Expand Down
2 changes: 1 addition & 1 deletion .dotnet/src/Custom/Assistants/AssistantCreationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public partial class AssistantCreationOptions
/// </summary>
[CodeGenMember("TopP")]
public float? NucleusSamplingFactor { get; set; }

internal AssistantCreationOptions(InternalCreateAssistantRequestModel model)
: this()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void IJsonModel<FunctionToolDefinition>.Write(Utf8JsonWriter writer, ModelReader

internal static void SerializeFunctionToolDefinition(FunctionToolDefinition instance, Utf8JsonWriter writer, ModelReaderWriterOptions options)
=> instance.WriteCore(writer, options);

protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
{
writer.WriteStartObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,31 @@ internal partial class InternalRunToolCallObjectFunction { }
internal partial class InternalListAssistantsResponse : IInternalListResponse<Assistant> { }

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

[CodeGenModel("ListThreadsResponse")]
internal partial class InternalListThreadsResponse : IInternalListResponse<AssistantThread> { }

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

[CodeGenModel("ListMessagesResponse")]
internal partial class InternalListMessagesResponse : IInternalListResponse<ThreadMessage> { }

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

[CodeGenModel("ListRunsResponse")]
internal partial class InternalListRunsResponse : IInternalListResponse<ThreadRun> { }

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

[CodeGenModel("ListRunStepsResponse")]
internal partial class InternalListRunStepsResponse : IInternalListResponse<RunStep> { }

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

[CodeGenModel("RunStepDetailsToolCallsFileSearchObject")]
internal partial class InternalRunStepFileSearchToolCallDetails { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal partial class InternalMessageImageFileContent
/// <summary> Initializes a new instance of <see cref="InternalMessageImageFileContent"/>. </summary>
internal InternalMessageImageFileContent(string imageFileId, MessageImageDetail? detail = null)
: this(new InternalMessageContentItemFileObjectImageFile(imageFileId, detail?.ToSerialString(), null))
{}
{ }

/// <summary> Initializes a new instance of <see cref="InternalMessageImageFileContent"/>. </summary>
/// <param name="imageFile"></param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal partial class InternalMessageImageUrlContent
/// <summary> Initializes a new instance of <see cref="InternalMessageImageUrlContent"/>. </summary>
internal InternalMessageImageUrlContent(Uri url, MessageImageDetail? detail = null)
: this(new InternalMessageContentImageUrlObjectImageUrl(url, detail?.ToSerialString(), null))
{}
{ }

/// <summary> Initializes a new instance of <see cref="InternalMessageImageUrlContent"/>. </summary>
/// <param name="imageUrl"></param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal partial class InternalRequiredFunctionToolCall : InternalRequiredToolCa
// - 'Type' is hidden, as the object discriminator does not carry additional value to the caller in the context
// of a strongly-typed object model
// - 'Function' is hidden and its constituent 'Name' and 'Arguments' members are promoted to direct visibility

[CodeGenMember("Type")]
private readonly object _type;
[CodeGenMember("Function")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal partial class InternalRunStepCodeInterpreterToolCallDetails
{
/// <inheritdoc cref="InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.Input"/>
public string Input => _codeInterpreter.Input;

/// <inheritdoc cref="InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.Outputs"/>
public IReadOnlyList<RunStepCodeInterpreterOutput> Outputs => _codeInterpreter.Outputs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal partial class AssistantsPageEnumerator : PageEnumerator<Assistant>
private readonly RequestOptions _options;

public virtual ClientPipeline Pipeline => _pipeline;

public AssistantsPageEnumerator(
ClientPipeline pipeline,
Uri endpoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal partial class MessagesPageEnumerator : PageEnumerator<ThreadMessage>
public MessagesPageEnumerator(
ClientPipeline pipeline,
Uri endpoint,
string threadId,
string threadId,
int? limit, string order, string after, string before,
RequestOptions options)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override BinaryData ToBytes()

return BinaryData.FromStream(stream);
}

public MessagesPageToken? GetNextPageToken(bool hasMore, string? lastId)
{
if (!hasMore || lastId is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override BinaryData ToBytes()

return BinaryData.FromStream(stream);
}

public RunStepsPageToken? GetNextPageToken(bool hasMore, string? lastId)
{
if (!hasMore || lastId is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override BinaryData ToBytes()

return BinaryData.FromStream(stream);
}

public RunsPageToken? GetNextPageToken(bool hasMore, string? lastId)
{
if (!hasMore || lastId is null)
Expand Down
4 changes: 2 additions & 2 deletions .dotnet/src/Custom/Assistants/MessageCreationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace OpenAI.Assistants;
/// </summary>
[CodeGenModel("CreateMessageRequest")]
[CodeGenSuppress("MessageCreationOptions", typeof(MessageRole), typeof(IEnumerable<MessageContent>))]
[CodeGenSerialization(nameof(Content), SerializationValueHook=nameof(SerializeContent))]
[CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContent))]
public partial class MessageCreationOptions
{
// CUSTOM: role is hidden, as this required property is promoted to a method parameter
Expand All @@ -32,7 +32,7 @@ public MessageCreationOptions()
new ChangeTrackingList<MessageCreationAttachment>(),
new ChangeTrackingDictionary<string, string>(),
new ChangeTrackingDictionary<string, BinaryData>())
{}
{ }

internal MessageCreationOptions(IEnumerable<MessageContent> content) : this()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private sealed class AsyncStreamingUpdateEnumerator : IAsyncEnumerator<Streaming
private bool _started;

public AsyncStreamingUpdateEnumerator(Func<Task<ClientResult>> getResultAsync,
AsyncStreamingUpdateCollection enumerable,
AsyncStreamingUpdateCollection enumerable,
CancellationToken cancellationToken)
{
Debug.Assert(getResultAsync is not null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class RunStepDetailsUpdate : StreamingUpdate
private readonly InternalRunStepDeltaStepDetailsToolCallsFunctionObject _asFunctionCall;

/// <inheritdoc cref="InternalRunStepDelta.Id"/>
public string StepId => _delta?.Id;
public string StepId => _delta?.Id;

/// <inheritdoc cref="InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation"/>
public string CreatedMessageId => _asMessageCreation?.MessageCreation?.MessageId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private sealed class StreamingUpdateEnumerator : IEnumerator<StreamingUpdate>
private StreamingUpdate? _current;
private bool _started;

public StreamingUpdateEnumerator(Func<ClientResult> getResult,
public StreamingUpdateEnumerator(Func<ClientResult> getResult,
StreamingUpdateCollection enumerable)
{
Debug.Assert(getResult is not null);
Expand Down
2 changes: 1 addition & 1 deletion .dotnet/src/Custom/Assistants/ThreadMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public partial class ThreadMessage
{
// CUSTOM: Made internal.
/// <summary> The object type, which is always `thread.message`. </summary>
[CodeGenMember("Object")]
[CodeGenMember("Object")]
internal InternalMessageObjectObject Object { get; } = InternalMessageObjectObject.ThreadMessage;


Expand Down
2 changes: 1 addition & 1 deletion .dotnet/src/Custom/Assistants/ToolDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace OpenAI.Assistants;

[CodeGenModel("AssistantToolDefinition")]
public abstract partial class ToolDefinition
{
{
public static CodeInterpreterToolDefinition CreateCodeInterpreter()
=> new CodeInterpreterToolDefinition();
public static FileSearchToolDefinition CreateFileSearch(int? maxResults = null)
Expand Down
2 changes: 1 addition & 1 deletion .dotnet/src/Custom/Assistants/ToolOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public partial class ToolOutput
/// <param name="output"> The output from the specified tool. </param>
public ToolOutput(string toolCallId, string output)
: this(toolCallId, output, null)
{}
{ }
}
2 changes: 1 addition & 1 deletion .dotnet/src/Custom/Assistants/ToolResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class ToolResources
public FileSearchToolResources FileSearch { get; set; }

public ToolResources()
{}
{ }

private void SerializeFileSearch(Utf8JsonWriter writer, ModelReaderWriterOptions options)
=> writer.WriteObjectValue(FileSearch, options);
Expand Down
2 changes: 1 addition & 1 deletion .dotnet/src/Custom/Assistants/VectorStoreCreationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ public VectorStoreCreationHelper(IEnumerable<string> fileIds, IDictionary<string

public VectorStoreCreationHelper(IEnumerable<OpenAIFileInfo> files, IDictionary<string, string> metadata = null)
: this(files?.Select(file => file.Id) ?? [], metadata)
{}
{ }
}
2 changes: 1 addition & 1 deletion .dotnet/src/Custom/Audio/AudioClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public virtual async Task<ClientResult<AudioTranslation>> TranslateAudioAsync(st
}

#endregion

private void CreateSpeechGenerationOptions(string text, GeneratedSpeechVoice voice, ref SpeechGenerationOptions options)
{
options.Input = text;
Expand Down
6 changes: 3 additions & 3 deletions .dotnet/src/Custom/Audio/AudioTimestampGranularities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public enum AudioTimestampGranularities
/// The default value that, when equivalent to a request's flags, specifies no specific audio timestamp granularity
/// and defers to the default timestamp behavior.
/// </summary>
Default = 0,
Default = 0,

/// <summary>
/// The value that, when present in the request's flags, specifies that audio information should include word-level
/// timestamp information.
/// </summary>
Word = 1,
Word = 1,

/// <summary>
/// The value that, when present in the request's flags, specifies that audio information should include
/// segment-level timestamp information.
/// </summary>
Segment = 2,
Segment = 2,
}
2 changes: 1 addition & 1 deletion .dotnet/src/Custom/Audio/GeneratedSpeechFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public enum GeneratedSpeechFormat
Wav,

/// <summary> PCM (pulse-code modulation). /// </summary>
[CodeGenMember("Pcm")]
[CodeGenMember("Pcm")]
Pcm,
}
2 changes: 1 addition & 1 deletion .dotnet/src/Custom/Audio/SpeechGenerationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class SpeechGenerationOptions
/// `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the
/// [Text to speech guide](/docs/guides/text-to-speech/voice-options).
/// </summary>
internal GeneratedSpeechVoice Voice { get; set; }
internal GeneratedSpeechVoice Voice { get; set; }

// CUSTOM: Made public now that there are no required properties.
/// <summary> Initializes a new instance of <see cref="SpeechGenerationOptions"/>. </summary>
Expand Down
4 changes: 2 additions & 2 deletions .dotnet/src/Custom/Chat/ChatMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected internal ChatMessage(ChatMessageRole role, IEnumerable<ChatMessageCont
Role = role;
foreach (ChatMessageContentPart contentPart in contentParts ?? [])
{
Content.Add(contentPart);
Content.Add(contentPart);
}
}

Expand All @@ -76,7 +76,7 @@ protected internal ChatMessage(ChatMessageRole role, string content)

// CUSTOM: use strongly-typed role.
[CodeGenMember("Role")]
internal ChatMessageRole Role { get; set; }
internal ChatMessageRole Role { get; set; }

/// <inheritdoc cref="SystemChatMessage(string)"/>
public static SystemChatMessage CreateSystemMessage(string content) => new(content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public InternalChatCompletionRequestMessageContentPartImageImageUrl(BinaryData i
internal InternalChatCompletionRequestMessageContentPartImageImageUrl(string url, ImageChatMessageContentPartDetail? detail, IDictionary<string, BinaryData> serializedAdditionalRawData)
{
Match parsedDataUri = ParseDataUriRegex().Match(url);

if (parsedDataUri.Success)
{
_imageBytes = BinaryData.FromBytes(Convert.FromBase64String(parsedDataUri.Groups["data"].Value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace OpenAI.Chat;
internal partial class UnknownChatMessage : IJsonModel<ChatMessage>
{
void IJsonModel<ChatMessage>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
=> CustomSerializationHelpers.SerializeInstance<ChatMessage,UnknownChatMessage>(this, WriteCore, writer, options);
=> CustomSerializationHelpers.SerializeInstance<ChatMessage, UnknownChatMessage>(this, WriteCore, writer, options);

internal static void WriteCore(UnknownChatMessage instance, Utf8JsonWriter writer, ModelReaderWriterOptions options)
{
Expand Down
Loading