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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal static void SerializeAssistantResponseFormat(AssistantResponseFormat fo
writer.WriteStartObject();
writer.WritePropertyName("type"u8);
writer.WriteStringValue(formatInstance._objectType);
writer.WriteSerializedAdditionalRawData(formatInstance._serializedAdditionalRawData, options);
writer.WriteSerializedAdditionalRawData(formatInstance.SerializedAdditionalRawData, options);
writer.WriteEndObject();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Custom/Assistants/AssistantResponseFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class AssistantResponseFormat
{
private readonly string _plainTextValue;
private readonly string _objectType;
private readonly IDictionary<string, BinaryData> _serializedAdditionalRawData;
private readonly IDictionary<string, BinaryData> SerializedAdditionalRawData;

private const string AutoValue = "auto";
private const string TextValue = "text";
Expand Down Expand Up @@ -62,7 +62,7 @@ internal AssistantResponseFormat(string plainTextValue, string objectType, IDict
{
_plainTextValue = plainTextValue;
_objectType = objectType;
_serializedAdditionalRawData = serializedAdditionalRawData ?? new ChangeTrackingDictionary<string, BinaryData>();
SerializedAdditionalRawData = serializedAdditionalRawData ?? new ChangeTrackingDictionary<string, BinaryData>();
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOption
writer.WriteStartObject();
writer.WritePropertyName("type"u8);
writer.WriteStringValue(Type);
writer.WriteSerializedAdditionalRawData(_serializedAdditionalRawData, options);
writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options);
writer.WriteEndObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOption
writer.WriteNumberValue(MaxResults.Value);
writer.WriteEndObject();
}
writer.WriteSerializedAdditionalRawData(_serializedAdditionalRawData, options);
writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options);
writer.WriteEndObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOption
writer.WriteObjectValue<InternalFunctionDefinition>(_internalFunction, options);
writer.WritePropertyName("type"u8);
writer.WriteStringValue(Type);
writer.WriteSerializedAdditionalRawData(_serializedAdditionalRawData, options);
writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options);
writer.WriteEndObject();
}
}
12 changes: 9 additions & 3 deletions src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,6 @@ internal readonly partial struct InternalCreateRunRequestModel { }
[CodeGenModel("CreateRunRequestToolChoice")]
internal readonly partial struct InternalCreateRunRequestToolChoice { }

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

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

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

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOption
writer.WriteStringValue(_type);
writer.WritePropertyName("image_file"u8);
writer.WriteObjectValue<InternalMessageContentItemFileObjectImageFile>(_imageFile, options);
writer.WriteSerializedAdditionalRawData(_serializedAdditionalRawData, options);
writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options);
writer.WriteEndObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOption
writer.WriteStringValue(_type);
writer.WritePropertyName("image_url"u8);
writer.WriteObjectValue<InternalMessageContentImageUrlObjectImageUrl>(_imageUrl, options);
writer.WriteSerializedAdditionalRawData(_serializedAdditionalRawData, options);
writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options);
writer.WriteEndObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOption
writer.WriteStringValue(Type.ToString());
writer.WritePropertyName("text"u8);
writer.WriteStringValue(InternalText);
writer.WriteSerializedAdditionalRawData(_serializedAdditionalRawData, options);
writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options);
writer.WriteEndObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOption
writer.WriteStringValue(_type);
writer.WritePropertyName("text"u8);
writer.WriteObjectValue<MessageContentTextObjectText>(_text, options);
writer.WriteSerializedAdditionalRawData(_serializedAdditionalRawData, options);
writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options);
writer.WriteEndObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOption
writer.WriteStartObject();
writer.WritePropertyName("type"u8);
writer.WriteStringValue(Type);
writer.WriteSerializedAdditionalRawData(_serializedAdditionalRawData, options);
writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options);
writer.WriteEndObject();
}
}
38 changes: 0 additions & 38 deletions src/Custom/Assistants/MessageTextContentAnnotation.cs

This file was deleted.

10 changes: 9 additions & 1 deletion src/Custom/Assistants/RunStepToolCall.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
using System;
using System.Collections.Generic;

namespace OpenAI.Assistants;

[CodeGenModel("RunStepDetailsToolCallsObjectToolCallsObject")]
public partial class RunStepToolCall
{
public string ToolCallId => AsCodeInterpreter?.Id ?? AsFunction?.Id ?? AsFileSearch?.Id;
public string ToolCallId
=> AsCodeInterpreter?.Id
?? AsFunction?.Id
?? AsFileSearch?.Id
?? (SerializedAdditionalRawData?.TryGetValue("id", out BinaryData idData) == true
? idData.ToString()
: null);

public string CodeInterpreterInput => AsCodeInterpreter?.Input;
public IReadOnlyList<RunStepCodeInterpreterOutput> CodeInterpreterOutputs => AsCodeInterpreter?.Outputs ?? [];

Expand Down
2 changes: 1 addition & 1 deletion src/Custom/Assistants/RunTruncationStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public partial class RunTruncationStrategy
/// </list>
/// </para>
/// </summary>
private IDictionary<string, BinaryData> _serializedAdditionalRawData;
private IDictionary<string, BinaryData> SerializedAdditionalRawData;

/// <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")]
Expand Down
13 changes: 11 additions & 2 deletions src/Custom/Assistants/Streaming/RunStepDetailsUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.ClientModel.Primitives;
using System.Collections.Generic;
using System.Text.Json;
Expand All @@ -9,7 +10,8 @@ namespace OpenAI.Assistants;
/// </summary>
public class RunStepDetailsUpdate : StreamingUpdate
{
private readonly InternalRunStepDelta _delta;
internal readonly InternalRunStepDelta _delta;
internal readonly InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject _toolCall;
private readonly InternalRunStepDeltaStepDetailsMessageCreationObject _asMessageCreation;
private readonly InternalRunStepDeltaStepDetailsToolCallsCodeObject _asCodeCall;
private readonly InternalRunStepDeltaStepDetailsToolCallsFileSearchObject _asFileSearchCall;
Expand All @@ -22,7 +24,13 @@ public class RunStepDetailsUpdate : StreamingUpdate
public string CreatedMessageId => _asMessageCreation?.MessageCreation?.MessageId;

/// <inheritdoc cref="InternalRunStepDeltaStepDetailsToolCallsCodeObject.Id"/>
public string ToolCallId => _asCodeCall?.Id ?? _asFileSearchCall?.Id ?? _asFunctionCall?.Id;
public string ToolCallId
=> _asCodeCall?.Id
?? _asFileSearchCall?.Id
?? _asFunctionCall?.Id
?? (_toolCall?.SerializedAdditionalRawData?.TryGetValue("id", out BinaryData idData) == true
? idData.ToString()
: null);

/// <inheritdoc cref="InternalRunStepDeltaStepDetailsToolCallsCodeObject.Index"/>
public int? ToolCallIndex => _asCodeCall?.Index ?? _asFileSearchCall?.Index ?? _asFunctionCall?.Index;
Expand Down Expand Up @@ -53,6 +61,7 @@ internal RunStepDetailsUpdate(
_asFileSearchCall = toolCall as InternalRunStepDeltaStepDetailsToolCallsFileSearchObject;
_asFunctionCall = toolCall as InternalRunStepDeltaStepDetailsToolCallsFunctionObject;
_delta = stepDelta;
_toolCall = toolCall;
}

internal static IEnumerable<RunStepDetailsUpdate> DeserializeRunStepDetailsUpdates(
Expand Down
48 changes: 36 additions & 12 deletions src/Custom/Assistants/Streaming/TextAnnotationUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,66 @@
namespace OpenAI.Assistants;
using System;

namespace OpenAI.Assistants;

public class TextAnnotationUpdate
{
/// <summary>
/// The index of the content item that this annotation applies to.
/// </summary>
public int ContentIndex => _fileSearchCitation?.Index ?? _codeCitation?.Index ?? -1;
public int ContentIndex
=> _fileSearchCitation?.Index
?? _codeCitation?.Index
?? (_internalAnnotation?.SerializedAdditionalRawData.TryGetValue("index", out BinaryData indexData) == true
? int.Parse(indexData.ToString())
: -1);

/// <summary>
/// The ID of the file cited by the <c>file_search</c> tool for this annotation.
/// The index in the message content at which the citation begins.
/// </summary>
public string InputFileId => _fileSearchCitation?.FileCitation?.FileId;
public int? StartIndex
=> _fileSearchCitation?.StartIndex
?? _codeCitation?.StartIndex
?? (_internalAnnotation?.SerializedAdditionalRawData.TryGetValue("start_index", out BinaryData indexData) == true
? int.Parse(indexData.ToString())
: null);

/// <summary>
/// The ID of the file that was generated by the <c>code_interpreter</c> tool for this citation.
/// The index in the message content at which the citation ends.
/// </summary>
public string OutputFileId => _codeCitation?.FilePath?.FileId;
public int? EndIndex
=> _fileSearchCitation?.EndIndex
?? _codeCitation?.EndIndex
?? (_internalAnnotation?.SerializedAdditionalRawData.TryGetValue("start_index", out BinaryData indexData) == true
? int.Parse(indexData.ToString())
: null);

/// <summary>
/// The index in the message content at which the citation begins.
/// The text in the message content that should be replaced.
/// </summary>
public int? StartIndex => _fileSearchCitation?.StartIndex ?? _codeCitation?.StartIndex;
public string TextToReplace
=> _fileSearchCitation?.Text
?? _codeCitation?.Text
?? (_internalAnnotation?.SerializedAdditionalRawData.TryGetValue("text", out BinaryData textData) == true
? textData.ToString()
: null);

/// <summary>
/// The index in the message content at which the citation ends.
/// The ID of the file cited by the <c>file_search</c> tool for this annotation.
/// </summary>
public int? EndIndex => _fileSearchCitation?.EndIndex ?? _codeCitation?.EndIndex;
public string InputFileId => _fileSearchCitation?.FileCitation?.FileId;

/// <summary>
/// The text in the message content that should be replaced.
/// The ID of the file that was generated by the <c>code_interpreter</c> tool for this citation.
/// </summary>
public string TextToReplace => _fileSearchCitation?.Text ?? _codeCitation?.Text;
public string OutputFileId => _codeCitation?.FilePath?.FileId;

internal readonly MessageDeltaTextContentAnnotation _internalAnnotation;
private readonly MessageDeltaContentTextAnnotationsFileCitationObject _fileSearchCitation;
private readonly MessageDeltaContentTextAnnotationsFilePathObject _codeCitation;

internal TextAnnotationUpdate(MessageDeltaTextContentAnnotation internalAnnotation)
{
_internalAnnotation = internalAnnotation;
_fileSearchCitation = internalAnnotation as MessageDeltaContentTextAnnotationsFileCitationObject;
_codeCitation = internalAnnotation as MessageDeltaContentTextAnnotationsFilePathObject;
}
Expand Down
41 changes: 30 additions & 11 deletions src/Custom/Assistants/TextAnnotation.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,56 @@
namespace OpenAI.Assistants;
using System;

namespace OpenAI.Assistants;

public class TextAnnotation
{
internal readonly MessageContentTextObjectAnnotation _internalAnnotation;
private readonly MessageContentTextAnnotationsFileCitationObject _fileSearchCitation;
private readonly MessageContentTextAnnotationsFilePathObject _codeCitation;

/// <summary>
/// The ID of the file cited by the <c>file_search</c> tool for this annotation.
/// The index in the message content at which the citation begins.
/// </summary>
public string InputFileId => _fileSearchCitation?.FileCitation?.FileId;
public int StartIndex
=> _fileSearchCitation?.StartIndex
?? _codeCitation?.StartIndex
?? (_internalAnnotation?.SerializedAdditionalRawData?.TryGetValue("start_index", out BinaryData indexData) == true
? int.Parse(indexData.ToString())
: -1);

/// <summary>
/// The ID of the file that was generated by the <c>code_interpreter</c> tool for this citation.
/// The index in the message content at which the citation ends.
/// </summary>
public string OutputFileId => _codeCitation?.FilePath?.FileId;
public int EndIndex =>
_fileSearchCitation?.EndIndex
?? _codeCitation?.EndIndex
?? (_internalAnnotation?.SerializedAdditionalRawData?.TryGetValue("end_index", out BinaryData indexData) == true
? int.Parse(indexData.ToString())
: -1);

/// <summary>
/// The index in the message content at which the citation begins.
/// The text in the message content that should be replaced.
/// </summary>
public int StartIndex => _fileSearchCitation?.StartIndex ?? _codeCitation?.StartIndex ?? -1;
public string TextToReplace =>
_fileSearchCitation?.Text
?? _codeCitation?.Text
?? (_internalAnnotation?.SerializedAdditionalRawData?.TryGetValue("text", out BinaryData textData) == true
? textData.ToString()
: null);

/// <summary>
/// The index in the message content at which the citation ends.
/// The ID of the file cited by the <c>file_search</c> tool for this annotation.
/// </summary>
public int EndIndex => _fileSearchCitation?.EndIndex ?? _codeCitation?.EndIndex ?? -1;
public string InputFileId => _fileSearchCitation?.FileCitation?.FileId;

/// <summary>
/// The text in the message content that should be replaced.
/// The ID of the file that was generated by the <c>code_interpreter</c> tool for this citation.
/// </summary>
public string TextToReplace => _fileSearchCitation?.Text ?? _codeCitation?.Text;
public string OutputFileId => _codeCitation?.FilePath?.FileId;

internal TextAnnotation(MessageContentTextObjectAnnotation internalAnnotation)
{
_internalAnnotation = internalAnnotation;
_fileSearchCitation = internalAnnotation as MessageContentTextAnnotationsFileCitationObject;
_codeCitation = internalAnnotation as MessageContentTextAnnotationsFilePathObject; ;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Custom/Assistants/ToolConstraint.Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal static void SerializeToolConstraint(ToolConstraint instance, Utf8JsonWr
writer.WriteStringValue(instance._objectFunctionName);
writer.WriteEndObject();
}
writer.WriteSerializedAdditionalRawData(instance._serializedAdditionalRawData, options);
writer.WriteSerializedAdditionalRawData(instance.SerializedAdditionalRawData, options);
writer.WriteEndObject();
}
}
Expand Down
Loading