diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ApiResponseFormat.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ApiResponseFormat.cs
new file mode 100644
index 000000000000..a9d6dc151976
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ApiResponseFormat.cs
@@ -0,0 +1,54 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ /// Possible API response formats.
+ internal readonly partial struct ApiResponseFormat : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public ApiResponseFormat(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string TextValue = "text";
+ private const string JsonObjectValue = "json_object";
+ private const string JsonSchemaValue = "json_schema";
+
+ /// `text` format should be used for requests involving any sort of ToolCall.
+ public static ApiResponseFormat Text { get; } = new ApiResponseFormat(TextValue);
+ /// Using `json_object` format will limit the usage of ToolCall to only functions.
+ public static ApiResponseFormat JsonObject { get; } = new ApiResponseFormat(JsonObjectValue);
+ /// Using `json_schema` format will ensure the model matches the supplied JSON schema.
+ public static ApiResponseFormat JsonSchema { get; } = new ApiResponseFormat(JsonSchemaValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(ApiResponseFormat left, ApiResponseFormat right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(ApiResponseFormat left, ApiResponseFormat right) => !left.Equals(right);
+ /// Converts a to a .
+ public static implicit operator ApiResponseFormat(string value) => new ApiResponseFormat(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is ApiResponseFormat other && Equals(other);
+ ///
+ public bool Equals(ApiResponseFormat 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;
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs
index 54d84a05db04..590f2636f4bb 100644
--- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs
@@ -76,13 +76,52 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
writer.WriteObjectValue(item, options);
}
writer.WriteEndArray();
- writer.WritePropertyName("file_ids"u8);
- writer.WriteStartArray();
- foreach (var item in FileIds)
+ if (ToolResources != null)
{
- writer.WriteStringValue(item);
+ writer.WritePropertyName("tool_resources"u8);
+ writer.WriteObjectValue(ToolResources, options);
+ }
+ else
+ {
+ writer.WriteNull("tool_resources");
+ }
+ if (Temperature != null)
+ {
+ writer.WritePropertyName("temperature"u8);
+ writer.WriteNumberValue(Temperature.Value);
+ }
+ else
+ {
+ writer.WriteNull("temperature");
+ }
+ if (TopP != null)
+ {
+ writer.WritePropertyName("top_p"u8);
+ writer.WriteNumberValue(TopP.Value);
+ }
+ else
+ {
+ writer.WriteNull("top_p");
+ }
+ if (Optional.IsDefined(ResponseFormat))
+ {
+ if (ResponseFormat != null)
+ {
+ writer.WritePropertyName("response_format"u8);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(ResponseFormat);
+#else
+ using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ else
+ {
+ writer.WriteNull("response_format");
+ }
}
- writer.WriteEndArray();
if (Metadata != null && Optional.IsCollectionDefined(Metadata))
{
writer.WritePropertyName("metadata"u8);
@@ -143,7 +182,10 @@ internal static Assistant DeserializeAssistant(JsonElement element, ModelReaderW
string model = default;
string instructions = default;
IReadOnlyList tools = default;
- IReadOnlyList fileIds = default;
+ ToolResources toolResources = default;
+ float? temperature = default;
+ float? topP = default;
+ BinaryData responseFormat = default;
IReadOnlyDictionary metadata = default;
IDictionary serializedAdditionalRawData = default;
Dictionary rawDataDictionary = new Dictionary();
@@ -209,14 +251,44 @@ internal static Assistant DeserializeAssistant(JsonElement element, ModelReaderW
tools = array;
continue;
}
- if (property.NameEquals("file_ids"u8))
+ if (property.NameEquals("tool_resources"u8))
{
- List array = new List();
- foreach (var item in property.Value.EnumerateArray())
+ if (property.Value.ValueKind == JsonValueKind.Null)
{
- array.Add(item.GetString());
+ toolResources = null;
+ continue;
+ }
+ toolResources = ToolResources.DeserializeToolResources(property.Value, options);
+ continue;
+ }
+ if (property.NameEquals("temperature"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ temperature = null;
+ continue;
+ }
+ temperature = property.Value.GetSingle();
+ continue;
+ }
+ if (property.NameEquals("top_p"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ topP = null;
+ continue;
+ }
+ topP = property.Value.GetSingle();
+ continue;
+ }
+ if (property.NameEquals("response_format"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ responseFormat = null;
+ continue;
}
- fileIds = array;
+ responseFormat = BinaryData.FromString(property.Value.GetRawText());
continue;
}
if (property.NameEquals("metadata"u8))
@@ -249,7 +321,10 @@ internal static Assistant DeserializeAssistant(JsonElement element, ModelReaderW
model,
instructions,
tools,
- fileIds,
+ toolResources,
+ temperature,
+ topP,
+ responseFormat,
metadata,
serializedAdditionalRawData);
}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs
index 34402e5480d9..09b938b95c0e 100644
--- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs
@@ -56,17 +56,29 @@ public partial class Assistant
///
/// The collection of tools enabled for the assistant.
/// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
- /// The available derived classes include , and .
+ /// The available derived classes include , and .
+ ///
+ ///
+ /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter`
+ /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.
+ ///
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random,
+ /// while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
+ /// So 0.1 means only the tokens comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
///
- /// A list of attached file IDs, ordered by creation date in ascending order.
/// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
- /// , , or is null.
- internal Assistant(string id, DateTimeOffset createdAt, string name, string description, string model, string instructions, IEnumerable tools, IEnumerable fileIds, IReadOnlyDictionary metadata)
+ /// , or is null.
+ internal Assistant(string id, DateTimeOffset createdAt, string name, string description, string model, string instructions, IEnumerable tools, ToolResources toolResources, float? temperature, float? topP, IReadOnlyDictionary metadata)
{
Argument.AssertNotNull(id, nameof(id));
Argument.AssertNotNull(model, nameof(model));
Argument.AssertNotNull(tools, nameof(tools));
- Argument.AssertNotNull(fileIds, nameof(fileIds));
Id = id;
CreatedAt = createdAt;
@@ -75,7 +87,9 @@ internal Assistant(string id, DateTimeOffset createdAt, string name, string desc
Model = model;
Instructions = instructions;
Tools = tools.ToList();
- FileIds = fileIds.ToList();
+ ToolResources = toolResources;
+ Temperature = temperature;
+ TopP = topP;
Metadata = metadata;
}
@@ -90,12 +104,26 @@ internal Assistant(string id, DateTimeOffset createdAt, string name, string desc
///
/// The collection of tools enabled for the assistant.
/// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
- /// The available derived classes include , and .
+ /// The available derived classes include , and .
+ ///
+ ///
+ /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter`
+ /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.
+ ///
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random,
+ /// while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
+ /// So 0.1 means only the tokens comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
///
- /// A list of attached file IDs, ordered by creation date in ascending order.
+ /// The response format of the tool calls used by this assistant.
/// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
/// Keeps track of any properties unknown to the library.
- internal Assistant(string id, string @object, DateTimeOffset createdAt, string name, string description, string model, string instructions, IReadOnlyList tools, IReadOnlyList fileIds, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData)
+ internal Assistant(string id, string @object, DateTimeOffset createdAt, string name, string description, string model, string instructions, IReadOnlyList tools, ToolResources toolResources, float? temperature, float? topP, BinaryData responseFormat, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData)
{
Id = id;
Object = @object;
@@ -105,7 +133,10 @@ internal Assistant(string id, string @object, DateTimeOffset createdAt, string n
Model = model;
Instructions = instructions;
Tools = tools;
- FileIds = fileIds;
+ ToolResources = toolResources;
+ Temperature = temperature;
+ TopP = topP;
+ ResponseFormat = responseFormat;
Metadata = metadata;
_serializedAdditionalRawData = serializedAdditionalRawData;
}
@@ -131,11 +162,71 @@ internal Assistant()
///
/// The collection of tools enabled for the assistant.
/// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
- /// The available derived classes include , and .
+ /// The available derived classes include , and .
///
public IReadOnlyList Tools { get; }
- /// A list of attached file IDs, ordered by creation date in ascending order.
- public IReadOnlyList FileIds { get; }
+ ///
+ /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter`
+ /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.
+ ///
+ public ToolResources ToolResources { get; }
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random,
+ /// while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ public float? Temperature { get; }
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
+ /// So 0.1 means only the tokens comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
+ ///
+ public float? TopP { get; }
+ ///
+ /// The response format of the tool calls used by this assistant.
+ ///
+ /// To assign an object to this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ ///
+ /// Supported types:
+ ///
+ /// -
+ ///
+ ///
+ /// -
+ ///
+ ///
+ /// -
+ ///
+ ///
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ public BinaryData ResponseFormat { get; }
/// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
public IReadOnlyDictionary Metadata { get; }
}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs
index d0f8a38f8d29..3e54e193e53e 100644
--- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs
@@ -82,15 +82,60 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
}
writer.WriteEndArray();
}
- if (Optional.IsCollectionDefined(FileIds))
+ if (Optional.IsDefined(ToolResources))
{
- writer.WritePropertyName("file_ids"u8);
- writer.WriteStartArray();
- foreach (var item in FileIds)
+ if (ToolResources != null)
{
- writer.WriteStringValue(item);
+ writer.WritePropertyName("tool_resources"u8);
+ writer.WriteObjectValue(ToolResources, options);
+ }
+ else
+ {
+ writer.WriteNull("tool_resources");
+ }
+ }
+ if (Optional.IsDefined(Temperature))
+ {
+ if (Temperature != null)
+ {
+ writer.WritePropertyName("temperature"u8);
+ writer.WriteNumberValue(Temperature.Value);
+ }
+ else
+ {
+ writer.WriteNull("temperature");
+ }
+ }
+ if (Optional.IsDefined(TopP))
+ {
+ if (TopP != null)
+ {
+ writer.WritePropertyName("top_p"u8);
+ writer.WriteNumberValue(TopP.Value);
+ }
+ else
+ {
+ writer.WriteNull("top_p");
+ }
+ }
+ if (Optional.IsDefined(ResponseFormat))
+ {
+ if (ResponseFormat != null)
+ {
+ writer.WritePropertyName("response_format"u8);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(ResponseFormat);
+#else
+ using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ else
+ {
+ writer.WriteNull("response_format");
}
- writer.WriteEndArray();
}
if (Optional.IsCollectionDefined(Metadata))
{
@@ -152,7 +197,10 @@ internal static AssistantCreationOptions DeserializeAssistantCreationOptions(Jso
string description = default;
string instructions = default;
IList tools = default;
- IList fileIds = default;
+ CreateToolResourcesOptions toolResources = default;
+ float? temperature = default;
+ float? topP = default;
+ BinaryData responseFormat = default;
IDictionary metadata = default;
IDictionary serializedAdditionalRawData = default;
Dictionary rawDataDictionary = new Dictionary();
@@ -207,18 +255,44 @@ internal static AssistantCreationOptions DeserializeAssistantCreationOptions(Jso
tools = array;
continue;
}
- if (property.NameEquals("file_ids"u8))
+ if (property.NameEquals("tool_resources"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
+ toolResources = null;
continue;
}
- List array = new List();
- foreach (var item in property.Value.EnumerateArray())
+ toolResources = CreateToolResourcesOptions.DeserializeCreateToolResourcesOptions(property.Value, options);
+ continue;
+ }
+ if (property.NameEquals("temperature"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ temperature = null;
+ continue;
+ }
+ temperature = property.Value.GetSingle();
+ continue;
+ }
+ if (property.NameEquals("top_p"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
{
- array.Add(item.GetString());
+ topP = null;
+ continue;
+ }
+ topP = property.Value.GetSingle();
+ continue;
+ }
+ if (property.NameEquals("response_format"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ responseFormat = null;
+ continue;
}
- fileIds = array;
+ responseFormat = BinaryData.FromString(property.Value.GetRawText());
continue;
}
if (property.NameEquals("metadata"u8))
@@ -247,7 +321,10 @@ internal static AssistantCreationOptions DeserializeAssistantCreationOptions(Jso
description,
instructions,
tools ?? new ChangeTrackingList(),
- fileIds ?? new ChangeTrackingList(),
+ toolResources,
+ temperature,
+ topP,
+ responseFormat,
metadata ?? new ChangeTrackingDictionary(),
serializedAdditionalRawData);
}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs
index 34372f563399..87275c6b0976 100644
--- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs
@@ -54,7 +54,6 @@ public AssistantCreationOptions(string model)
Model = model;
Tools = new ChangeTrackingList();
- FileIds = new ChangeTrackingList();
Metadata = new ChangeTrackingDictionary();
}
@@ -66,19 +65,36 @@ public AssistantCreationOptions(string model)
///
/// The collection of tools to enable for the new assistant.
/// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
- /// The available derived classes include , and .
+ /// The available derived classes include , and .
///
- /// A list of previously uploaded file IDs to attach to the assistant.
+ ///
+ /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter`
+ /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.
+ ///
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random,
+ /// while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
+ /// So 0.1 means only the tokens comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
+ ///
+ /// The response format of the tool calls used by this assistant.
/// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
/// Keeps track of any properties unknown to the library.
- internal AssistantCreationOptions(string model, string name, string description, string instructions, IList tools, IList fileIds, IDictionary metadata, IDictionary serializedAdditionalRawData)
+ internal AssistantCreationOptions(string model, string name, string description, string instructions, IList tools, CreateToolResourcesOptions toolResources, float? temperature, float? topP, BinaryData responseFormat, IDictionary metadata, IDictionary serializedAdditionalRawData)
{
Model = model;
Name = name;
Description = description;
Instructions = instructions;
Tools = tools;
- FileIds = fileIds;
+ ToolResources = toolResources;
+ Temperature = temperature;
+ TopP = topP;
+ ResponseFormat = responseFormat;
Metadata = metadata;
_serializedAdditionalRawData = serializedAdditionalRawData;
}
@@ -99,11 +115,71 @@ internal AssistantCreationOptions()
///
/// The collection of tools to enable for the new assistant.
/// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
- /// The available derived classes include , and .
+ /// The available derived classes include , and .
///
public IList Tools { get; }
- /// A list of previously uploaded file IDs to attach to the assistant.
- public IList FileIds { get; }
+ ///
+ /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter`
+ /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.
+ ///
+ public CreateToolResourcesOptions ToolResources { get; set; }
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random,
+ /// while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ public float? Temperature { get; set; }
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
+ /// So 0.1 means only the tokens comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
+ ///
+ public float? TopP { get; set; }
+ ///
+ /// The response format of the tool calls used by this assistant.
+ ///
+ /// To assign an object to this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ ///
+ /// Supported types:
+ ///
+ /// -
+ ///
+ ///
+ /// -
+ ///
+ ///
+ /// -
+ ///
+ ///
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ public BinaryData ResponseFormat { get; set; }
/// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
public IDictionary Metadata { get; set; }
}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantStreamEvent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantStreamEvent.cs
new file mode 100644
index 000000000000..3c35b2590d78
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantStreamEvent.cs
@@ -0,0 +1,134 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ ///
+ /// Each event in a server-sent events stream has an `event` and `data` property:
+ ///
+ /// ```
+ /// event: thread.created
+ /// data: {"id": "thread_123", "object": "thread", ...}
+ /// ```
+ ///
+ /// We emit events whenever a new object is created, transitions to a new state, or is being
+ /// streamed in parts (deltas). For example, we emit `thread.run.created` when a new run
+ /// is created, `thread.run.completed` when a run completes, and so on. When an Assistant chooses
+ /// to create a message during a run, we emit a `thread.message.created event`, a
+ /// `thread.message.in_progress` event, many `thread.message.delta` events, and finally a
+ /// `thread.message.completed` event.
+ ///
+ /// We may add additional events over time, so we recommend handling unknown events gracefully
+ /// in your code.
+ ///
+ public readonly partial struct AssistantStreamEvent : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public AssistantStreamEvent(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string ThreadCreatedValue = "thread.created";
+ private const string ThreadRunCreatedValue = "thread.run.created";
+ private const string ThreadRunQueuedValue = "thread.run.queued";
+ private const string ThreadRunInProgressValue = "thread.run.in_progress";
+ private const string ThreadRunRequiresActionValue = "thread.run.requires_action";
+ private const string ThreadRunCompletedValue = "thread.run.completed";
+ private const string ThreadRunFailedValue = "thread.run.failed";
+ private const string ThreadRunCancellingValue = "thread.run.cancelling";
+ private const string ThreadRunCancelledValue = "thread.run.cancelled";
+ private const string ThreadRunExpiredValue = "thread.run.expired";
+ private const string ThreadRunStepCreatedValue = "thread.run.step.created";
+ private const string ThreadRunStepInProgressValue = "thread.run.step.in_progress";
+ private const string ThreadRunStepDeltaValue = "thread.run.step.delta";
+ private const string ThreadRunStepCompletedValue = "thread.run.step.completed";
+ private const string ThreadRunStepFailedValue = "thread.run.step.failed";
+ private const string ThreadRunStepCancelledValue = "thread.run.step.cancelled";
+ private const string ThreadRunStepExpiredValue = "thread.run.step.expired";
+ private const string ThreadMessageCreatedValue = "thread.message.created";
+ private const string ThreadMessageInProgressValue = "thread.message.in_progress";
+ private const string ThreadMessageDeltaValue = "thread.message.delta";
+ private const string ThreadMessageCompletedValue = "thread.message.completed";
+ private const string ThreadMessageIncompleteValue = "thread.message.incomplete";
+ private const string ErrorValue = "error";
+ private const string DoneValue = "done";
+
+ /// Event sent when a new thread is created. The data of this event is of type AssistantThread.
+ public static AssistantStreamEvent ThreadCreated { get; } = new AssistantStreamEvent(ThreadCreatedValue);
+ /// Event sent when a new run is created. The data of this event is of type ThreadRun.
+ public static AssistantStreamEvent ThreadRunCreated { get; } = new AssistantStreamEvent(ThreadRunCreatedValue);
+ /// Event sent when a run moves to `queued` status. The data of this event is of type ThreadRun.
+ public static AssistantStreamEvent ThreadRunQueued { get; } = new AssistantStreamEvent(ThreadRunQueuedValue);
+ /// Event sent when a run moves to `in_progress` status. The data of this event is of type ThreadRun.
+ public static AssistantStreamEvent ThreadRunInProgress { get; } = new AssistantStreamEvent(ThreadRunInProgressValue);
+ /// Event sent when a run moves to `requires_action` status. The data of this event is of type ThreadRun.
+ public static AssistantStreamEvent ThreadRunRequiresAction { get; } = new AssistantStreamEvent(ThreadRunRequiresActionValue);
+ /// Event sent when a run is completed. The data of this event is of type ThreadRun.
+ public static AssistantStreamEvent ThreadRunCompleted { get; } = new AssistantStreamEvent(ThreadRunCompletedValue);
+ /// Event sent when a run fails. The data of this event is of type ThreadRun.
+ public static AssistantStreamEvent ThreadRunFailed { get; } = new AssistantStreamEvent(ThreadRunFailedValue);
+ /// Event sent when a run moves to `cancelling` status. The data of this event is of type ThreadRun.
+ public static AssistantStreamEvent ThreadRunCancelling { get; } = new AssistantStreamEvent(ThreadRunCancellingValue);
+ /// Event sent when a run is cancelled. The data of this event is of type ThreadRun.
+ public static AssistantStreamEvent ThreadRunCancelled { get; } = new AssistantStreamEvent(ThreadRunCancelledValue);
+ /// Event sent when a run is expired. The data of this event is of type ThreadRun.
+ public static AssistantStreamEvent ThreadRunExpired { get; } = new AssistantStreamEvent(ThreadRunExpiredValue);
+ /// Event sent when a new thread run step is created. The data of this event is of type RunStep.
+ public static AssistantStreamEvent ThreadRunStepCreated { get; } = new AssistantStreamEvent(ThreadRunStepCreatedValue);
+ /// Event sent when a run step moves to `in_progress` status. The data of this event is of type RunStep.
+ public static AssistantStreamEvent ThreadRunStepInProgress { get; } = new AssistantStreamEvent(ThreadRunStepInProgressValue);
+ /// Event sent when a run stepis being streamed. The data of this event is of type RunStepDeltaChunk.
+ public static AssistantStreamEvent ThreadRunStepDelta { get; } = new AssistantStreamEvent(ThreadRunStepDeltaValue);
+ /// Event sent when a run step is completed. The data of this event is of type RunStep.
+ public static AssistantStreamEvent ThreadRunStepCompleted { get; } = new AssistantStreamEvent(ThreadRunStepCompletedValue);
+ /// Event sent when a run step fails. The data of this event is of type RunStep.
+ public static AssistantStreamEvent ThreadRunStepFailed { get; } = new AssistantStreamEvent(ThreadRunStepFailedValue);
+ /// Event sent when a run step is cancelled. The data of this event is of type RunStep.
+ public static AssistantStreamEvent ThreadRunStepCancelled { get; } = new AssistantStreamEvent(ThreadRunStepCancelledValue);
+ /// Event sent when a run step is expired. The data of this event is of type RunStep.
+ public static AssistantStreamEvent ThreadRunStepExpired { get; } = new AssistantStreamEvent(ThreadRunStepExpiredValue);
+ /// Event sent when a new message is created. The data of this event is of type ThreadMessage.
+ public static AssistantStreamEvent ThreadMessageCreated { get; } = new AssistantStreamEvent(ThreadMessageCreatedValue);
+ /// Event sent when a message moves to `in_progress` status. The data of this event is of type ThreadMessage.
+ public static AssistantStreamEvent ThreadMessageInProgress { get; } = new AssistantStreamEvent(ThreadMessageInProgressValue);
+ /// Event sent when a message is being streamed. The data of this event is of type MessageDeltaChunk.
+ public static AssistantStreamEvent ThreadMessageDelta { get; } = new AssistantStreamEvent(ThreadMessageDeltaValue);
+ /// Event sent when a message is completed. The data of this event is of type ThreadMessage.
+ public static AssistantStreamEvent ThreadMessageCompleted { get; } = new AssistantStreamEvent(ThreadMessageCompletedValue);
+ /// Event sent before a message is completed. The data of this event is of type ThreadMessage.
+ public static AssistantStreamEvent ThreadMessageIncomplete { get; } = new AssistantStreamEvent(ThreadMessageIncompleteValue);
+ /// Event sent when an error occurs, such as an internal server error or a timeout.
+ public static AssistantStreamEvent Error { get; } = new AssistantStreamEvent(ErrorValue);
+ /// Event sent when the stream is done.
+ public static AssistantStreamEvent Done { get; } = new AssistantStreamEvent(DoneValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(AssistantStreamEvent left, AssistantStreamEvent right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(AssistantStreamEvent left, AssistantStreamEvent right) => !left.Equals(right);
+ /// Converts a to a .
+ public static implicit operator AssistantStreamEvent(string value) => new AssistantStreamEvent(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is AssistantStreamEvent other && Equals(other);
+ ///
+ public bool Equals(AssistantStreamEvent 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;
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs
index 568e554f63ce..0c33c423a7cb 100644
--- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs
@@ -40,6 +40,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
writer.WriteStringValue(Object);
writer.WritePropertyName("created_at"u8);
writer.WriteNumberValue(CreatedAt, "U");
+ if (ToolResources != null)
+ {
+ writer.WritePropertyName("tool_resources"u8);
+ writer.WriteObjectValue(ToolResources, options);
+ }
+ else
+ {
+ writer.WriteNull("tool_resources");
+ }
if (Metadata != null && Optional.IsCollectionDefined(Metadata))
{
writer.WritePropertyName("metadata"u8);
@@ -95,6 +104,7 @@ internal static AssistantThread DeserializeAssistantThread(JsonElement element,
string id = default;
string @object = default;
DateTimeOffset createdAt = default;
+ ToolResources toolResources = default;
IReadOnlyDictionary metadata = default;
IDictionary serializedAdditionalRawData = default;
Dictionary rawDataDictionary = new Dictionary();
@@ -115,6 +125,16 @@ internal static AssistantThread DeserializeAssistantThread(JsonElement element,
createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64());
continue;
}
+ if (property.NameEquals("tool_resources"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ toolResources = null;
+ continue;
+ }
+ toolResources = ToolResources.DeserializeToolResources(property.Value, options);
+ continue;
+ }
if (property.NameEquals("metadata"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
@@ -136,7 +156,13 @@ internal static AssistantThread DeserializeAssistantThread(JsonElement element,
}
}
serializedAdditionalRawData = rawDataDictionary;
- return new AssistantThread(id, @object, createdAt, metadata, serializedAdditionalRawData);
+ return new AssistantThread(
+ id,
+ @object,
+ createdAt,
+ toolResources,
+ metadata,
+ serializedAdditionalRawData);
}
BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs
index 55fb2ac9a88e..11820b0ed0b6 100644
--- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs
@@ -48,14 +48,20 @@ public partial class AssistantThread
/// Initializes a new instance of .
/// The identifier, which can be referenced in API endpoints.
/// The Unix timestamp, in seconds, representing when this object was created.
+ ///
+ /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type
+ /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list
+ /// of vector store IDs.
+ ///
/// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
/// is null.
- internal AssistantThread(string id, DateTimeOffset createdAt, IReadOnlyDictionary metadata)
+ internal AssistantThread(string id, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata)
{
Argument.AssertNotNull(id, nameof(id));
Id = id;
CreatedAt = createdAt;
+ ToolResources = toolResources;
Metadata = metadata;
}
@@ -63,13 +69,19 @@ internal AssistantThread(string id, DateTimeOffset createdAt, IReadOnlyDictionar
/// The identifier, which can be referenced in API endpoints.
/// The object type, which is always 'thread'.
/// The Unix timestamp, in seconds, representing when this object was created.
+ ///
+ /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type
+ /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list
+ /// of vector store IDs.
+ ///
/// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
/// Keeps track of any properties unknown to the library.
- internal AssistantThread(string id, string @object, DateTimeOffset createdAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData)
+ internal AssistantThread(string id, string @object, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData)
{
Id = id;
Object = @object;
CreatedAt = createdAt;
+ ToolResources = toolResources;
Metadata = metadata;
_serializedAdditionalRawData = serializedAdditionalRawData;
}
@@ -84,6 +96,12 @@ internal AssistantThread()
/// The Unix timestamp, in seconds, representing when this object was created.
public DateTimeOffset CreatedAt { get; }
+ ///
+ /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type
+ /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list
+ /// of vector store IDs.
+ ///
+ public ToolResources ToolResources { get; }
/// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
public IReadOnlyDictionary Metadata { get; }
}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs
index 4c346f4c5b45..14aac63b59ed 100644
--- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs
@@ -44,6 +44,18 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
}
writer.WriteEndArray();
}
+ if (Optional.IsDefined(ToolResources))
+ {
+ if (ToolResources != null)
+ {
+ writer.WritePropertyName("tool_resources"u8);
+ writer.WriteObjectValue(ToolResources, options);
+ }
+ else
+ {
+ writer.WriteNull("tool_resources");
+ }
+ }
if (Optional.IsCollectionDefined(Metadata))
{
if (Metadata != null)
@@ -99,7 +111,8 @@ internal static AssistantThreadCreationOptions DeserializeAssistantThreadCreatio
{
return null;
}
- IList messages = default;
+ IList messages = default;
+ CreateToolResourcesOptions toolResources = default;
IDictionary metadata = default;
IDictionary serializedAdditionalRawData = default;
Dictionary rawDataDictionary = new Dictionary();
@@ -111,14 +124,24 @@ internal static AssistantThreadCreationOptions DeserializeAssistantThreadCreatio
{
continue;
}
- List array = new List();
+ List array = new List();
foreach (var item in property.Value.EnumerateArray())
{
- array.Add(ThreadInitializationMessage.DeserializeThreadInitializationMessage(item, options));
+ array.Add(ThreadMessageOptions.DeserializeThreadMessageOptions(item, options));
}
messages = array;
continue;
}
+ if (property.NameEquals("tool_resources"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ toolResources = null;
+ continue;
+ }
+ toolResources = CreateToolResourcesOptions.DeserializeCreateToolResourcesOptions(property.Value, options);
+ continue;
+ }
if (property.NameEquals("metadata"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
@@ -139,7 +162,7 @@ internal static AssistantThreadCreationOptions DeserializeAssistantThreadCreatio
}
}
serializedAdditionalRawData = rawDataDictionary;
- return new AssistantThreadCreationOptions(messages ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData);
+ return new AssistantThreadCreationOptions(messages ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData);
}
BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs
index 2df216a2c7e8..086af4d9dc8a 100644
--- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs
@@ -48,23 +48,35 @@ public partial class AssistantThreadCreationOptions
/// Initializes a new instance of .
public AssistantThreadCreationOptions()
{
- Messages = new ChangeTrackingList();
+ Messages = new ChangeTrackingList();
Metadata = new ChangeTrackingDictionary();
}
/// Initializes a new instance of .
/// The initial messages to associate with the new thread.
+ ///
+ /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the
+ /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires
+ /// a list of vector store IDs.
+ ///
/// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
/// Keeps track of any properties unknown to the library.
- internal AssistantThreadCreationOptions(IList messages, IDictionary metadata, IDictionary serializedAdditionalRawData)
+ internal AssistantThreadCreationOptions(IList messages, CreateToolResourcesOptions toolResources, IDictionary metadata, IDictionary serializedAdditionalRawData)
{
Messages = messages;
+ ToolResources = toolResources;
Metadata = metadata;
_serializedAdditionalRawData = serializedAdditionalRawData;
}
/// The initial messages to associate with the new thread.
- public IList Messages { get; }
+ public IList Messages { get; }
+ ///
+ /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the
+ /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires
+ /// a list of vector store IDs.
+ ///
+ public CreateToolResourcesOptions ToolResources { get; set; }
/// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
public IDictionary Metadata { get; set; }
}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.Serialization.cs
new file mode 100644
index 000000000000..3deab8002cf1
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.Serialization.cs
@@ -0,0 +1,138 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ [PersistableModelProxy(typeof(UnknownAssistantsApiResponseFormat))]
+ public partial class AssistantsApiResponseFormat : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormat)} does not support writing '{format}' format.");
+ }
+
+ if (Optional.IsDefined(Type))
+ {
+ writer.WritePropertyName("type"u8);
+ writer.WriteStringValue(Type.Value.ToString());
+ }
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ AssistantsApiResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormat)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAssistantsApiResponseFormat(document.RootElement, options);
+ }
+
+ internal static AssistantsApiResponseFormat DeserializeAssistantsApiResponseFormat(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ if (element.TryGetProperty("type", out JsonElement discriminator))
+ {
+ switch (discriminator.GetString())
+ {
+ case "json_object": return AssistantsApiResponseFormatJsonObject.DeserializeAssistantsApiResponseFormatJsonObject(element, options);
+ case "json_schema": return AssistantsApiResponseFormatJsonSchema.DeserializeAssistantsApiResponseFormatJsonSchema(element, options);
+ case "text": return AssistantsApiResponseFormatText.DeserializeAssistantsApiResponseFormatText(element, options);
+ }
+ }
+ return UnknownAssistantsApiResponseFormat.DeserializeUnknownAssistantsApiResponseFormat(element, options);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormat)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AssistantsApiResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAssistantsApiResponseFormat(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormat)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static AssistantsApiResponseFormat FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAssistantsApiResponseFormat(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.cs
new file mode 100644
index 000000000000..85723ba24c31
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.cs
@@ -0,0 +1,70 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ ///
+ /// An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run.
+ /// If `text` the model can return text or any value needed.
+ /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
+ /// The available derived classes include , and .
+ ///
+ public abstract partial class AssistantsApiResponseFormat
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private protected IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ protected AssistantsApiResponseFormat()
+ {
+ }
+
+ /// Initializes a new instance of .
+ /// Must be one of `text`, `json_object` or `json_schema` .
+ /// Keeps track of any properties unknown to the library.
+ internal AssistantsApiResponseFormat(ApiResponseFormat? type, IDictionary serializedAdditionalRawData)
+ {
+ Type = type;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Must be one of `text`, `json_object` or `json_schema` .
+ internal ApiResponseFormat? Type { get; set; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonObject.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonObject.Serialization.cs
new file mode 100644
index 000000000000..2a0cb536541a
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonObject.Serialization.cs
@@ -0,0 +1,130 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ public partial class AssistantsApiResponseFormatJsonObject : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonObject)} does not support writing '{format}' format.");
+ }
+
+ base.JsonModelWriteCore(writer, options);
+ }
+
+ AssistantsApiResponseFormatJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonObject)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAssistantsApiResponseFormatJsonObject(document.RootElement, options);
+ }
+
+ internal static AssistantsApiResponseFormatJsonObject DeserializeAssistantsApiResponseFormatJsonObject(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ ApiResponseFormat? type = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("type"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ type = new ApiResponseFormat(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AssistantsApiResponseFormatJsonObject(type, serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonObject)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AssistantsApiResponseFormatJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAssistantsApiResponseFormatJsonObject(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonObject)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static new AssistantsApiResponseFormatJsonObject FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAssistantsApiResponseFormatJsonObject(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal override RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonObject.cs
new file mode 100644
index 000000000000..596e3ead3c16
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonObject.cs
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ /// An object describing expected output of the model as a JSON object.
+ public partial class AssistantsApiResponseFormatJsonObject : AssistantsApiResponseFormat
+ {
+ /// Initializes a new instance of .
+ public AssistantsApiResponseFormatJsonObject()
+ {
+ Type = Assistants.ApiResponseFormat?.JsonObject;
+ }
+
+ /// Initializes a new instance of .
+ /// Must be one of `text`, `json_object` or `json_schema` .
+ /// Keeps track of any properties unknown to the library.
+ internal AssistantsApiResponseFormatJsonObject(ApiResponseFormat? type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData)
+ {
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchema.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchema.Serialization.cs
new file mode 100644
index 000000000000..ab75f3e95e18
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchema.Serialization.cs
@@ -0,0 +1,138 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ public partial class AssistantsApiResponseFormatJsonSchema : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonSchema)} does not support writing '{format}' format.");
+ }
+
+ base.JsonModelWriteCore(writer, options);
+ writer.WritePropertyName("json_schema"u8);
+ writer.WriteObjectValue(JsonSchema, options);
+ }
+
+ AssistantsApiResponseFormatJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonSchema)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAssistantsApiResponseFormatJsonSchema(document.RootElement, options);
+ }
+
+ internal static AssistantsApiResponseFormatJsonSchema DeserializeAssistantsApiResponseFormatJsonSchema(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ AssistantsApiResponseFormatJsonSchemaJsonSchema jsonSchema = default;
+ ApiResponseFormat? type = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("json_schema"u8))
+ {
+ jsonSchema = AssistantsApiResponseFormatJsonSchemaJsonSchema.DeserializeAssistantsApiResponseFormatJsonSchemaJsonSchema(property.Value, options);
+ continue;
+ }
+ if (property.NameEquals("type"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ type = new ApiResponseFormat(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AssistantsApiResponseFormatJsonSchema(type, serializedAdditionalRawData, jsonSchema);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonSchema)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AssistantsApiResponseFormatJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAssistantsApiResponseFormatJsonSchema(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonSchema)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static new AssistantsApiResponseFormatJsonSchema FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAssistantsApiResponseFormatJsonSchema(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal override RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchema.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchema.cs
new file mode 100644
index 000000000000..1b9f510138e2
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchema.cs
@@ -0,0 +1,44 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ /// An object describing expected output of the model to match a JSON schema.
+ public partial class AssistantsApiResponseFormatJsonSchema : AssistantsApiResponseFormat
+ {
+ /// Initializes a new instance of .
+ /// The JSON schema that the model must output.
+ /// is null.
+ public AssistantsApiResponseFormatJsonSchema(AssistantsApiResponseFormatJsonSchemaJsonSchema jsonSchema)
+ {
+ Argument.AssertNotNull(jsonSchema, nameof(jsonSchema));
+
+ Type = Assistants.ApiResponseFormat?.JsonSchema;
+ JsonSchema = jsonSchema;
+ }
+
+ /// Initializes a new instance of .
+ /// Must be one of `text`, `json_object` or `json_schema` .
+ /// Keeps track of any properties unknown to the library.
+ /// The JSON schema that the model must output.
+ internal AssistantsApiResponseFormatJsonSchema(ApiResponseFormat? type, IDictionary serializedAdditionalRawData, AssistantsApiResponseFormatJsonSchemaJsonSchema jsonSchema) : base(type, serializedAdditionalRawData)
+ {
+ JsonSchema = jsonSchema;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal AssistantsApiResponseFormatJsonSchema()
+ {
+ }
+
+ /// The JSON schema that the model must output.
+ public AssistantsApiResponseFormatJsonSchemaJsonSchema JsonSchema { get; set; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchemaJsonSchema.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchemaJsonSchema.Serialization.cs
new file mode 100644
index 000000000000..3ce87ee9a38f
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchemaJsonSchema.Serialization.cs
@@ -0,0 +1,183 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ public partial class AssistantsApiResponseFormatJsonSchemaJsonSchema : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonSchemaJsonSchema)} does not support writing '{format}' format.");
+ }
+
+ if (Optional.IsDefined(Description))
+ {
+ writer.WritePropertyName("description"u8);
+ writer.WriteStringValue(Description);
+ }
+ writer.WritePropertyName("name"u8);
+ writer.WriteStringValue(Name);
+ writer.WritePropertyName("schema"u8);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(Schema);
+#else
+ using (JsonDocument document = JsonDocument.Parse(Schema, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ if (Optional.IsDefined(Strict))
+ {
+ writer.WritePropertyName("strict"u8);
+ writer.WriteBooleanValue(Strict.Value);
+ }
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ AssistantsApiResponseFormatJsonSchemaJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonSchemaJsonSchema)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAssistantsApiResponseFormatJsonSchemaJsonSchema(document.RootElement, options);
+ }
+
+ internal static AssistantsApiResponseFormatJsonSchemaJsonSchema DeserializeAssistantsApiResponseFormatJsonSchemaJsonSchema(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string description = default;
+ string name = default;
+ BinaryData schema = default;
+ bool? strict = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("description"u8))
+ {
+ description = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("name"u8))
+ {
+ name = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("schema"u8))
+ {
+ schema = BinaryData.FromString(property.Value.GetRawText());
+ continue;
+ }
+ if (property.NameEquals("strict"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ strict = property.Value.GetBoolean();
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AssistantsApiResponseFormatJsonSchemaJsonSchema(description, name, schema, strict, serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonSchemaJsonSchema)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AssistantsApiResponseFormatJsonSchemaJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAssistantsApiResponseFormatJsonSchemaJsonSchema(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatJsonSchemaJsonSchema)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static AssistantsApiResponseFormatJsonSchemaJsonSchema FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAssistantsApiResponseFormatJsonSchemaJsonSchema(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchemaJsonSchema.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchemaJsonSchema.cs
new file mode 100644
index 000000000000..ce281b777a78
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatJsonSchemaJsonSchema.cs
@@ -0,0 +1,119 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ /// The AssistantsApiResponseFormatJsonSchemaJsonSchema.
+ public partial class AssistantsApiResponseFormatJsonSchemaJsonSchema
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ /// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
+ /// The schema for the response format, described as a JSON Schema object.
+ /// or is null.
+ public AssistantsApiResponseFormatJsonSchemaJsonSchema(string name, BinaryData schema)
+ {
+ Argument.AssertNotNull(name, nameof(name));
+ Argument.AssertNotNull(schema, nameof(schema));
+
+ Name = name;
+ Schema = schema;
+ }
+
+ /// Initializes a new instance of .
+ /// A description of what the response format is for, used by the model to determine how to respond in the format.
+ /// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
+ /// The schema for the response format, described as a JSON Schema object.
+ /// Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the Structured Outputs guide.
+ /// Keeps track of any properties unknown to the library.
+ internal AssistantsApiResponseFormatJsonSchemaJsonSchema(string description, string name, BinaryData schema, bool? strict, IDictionary serializedAdditionalRawData)
+ {
+ Description = description;
+ Name = name;
+ Schema = schema;
+ Strict = strict;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal AssistantsApiResponseFormatJsonSchemaJsonSchema()
+ {
+ }
+
+ /// A description of what the response format is for, used by the model to determine how to respond in the format.
+ public string Description { get; set; }
+ /// The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
+ public string Name { get; set; }
+ ///
+ /// The schema for the response format, described as a JSON Schema object.
+ ///
+ /// To assign an object to this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ public BinaryData Schema { get; set; }
+ /// Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the Structured Outputs guide.
+ public bool? Strict { get; set; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatMode.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatMode.cs
new file mode 100644
index 000000000000..56e7d3f9a04b
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatMode.cs
@@ -0,0 +1,48 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ /// Represents the mode in which the model will handle the return format of a tool call.
+ public readonly partial struct AssistantsApiResponseFormatMode : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public AssistantsApiResponseFormatMode(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string AutoValue = "auto";
+
+ /// Default value. Let the model handle the return format.
+ public static AssistantsApiResponseFormatMode Auto { get; } = new AssistantsApiResponseFormatMode(AutoValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(AssistantsApiResponseFormatMode left, AssistantsApiResponseFormatMode right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(AssistantsApiResponseFormatMode left, AssistantsApiResponseFormatMode right) => !left.Equals(right);
+ /// Converts a to a .
+ public static implicit operator AssistantsApiResponseFormatMode(string value) => new AssistantsApiResponseFormatMode(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is AssistantsApiResponseFormatMode other && Equals(other);
+ ///
+ public bool Equals(AssistantsApiResponseFormatMode 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;
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatText.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatText.Serialization.cs
new file mode 100644
index 000000000000..b1fc00fadf3b
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatText.Serialization.cs
@@ -0,0 +1,130 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ public partial class AssistantsApiResponseFormatText : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatText)} does not support writing '{format}' format.");
+ }
+
+ base.JsonModelWriteCore(writer, options);
+ }
+
+ AssistantsApiResponseFormatText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatText)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAssistantsApiResponseFormatText(document.RootElement, options);
+ }
+
+ internal static AssistantsApiResponseFormatText DeserializeAssistantsApiResponseFormatText(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ ApiResponseFormat? type = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("type"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ type = new ApiResponseFormat(property.Value.GetString());
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AssistantsApiResponseFormatText(type, serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatText)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AssistantsApiResponseFormatText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAssistantsApiResponseFormatText(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AssistantsApiResponseFormatText)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static new AssistantsApiResponseFormatText FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAssistantsApiResponseFormatText(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal override RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatText.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatText.cs
new file mode 100644
index 000000000000..d0a8845001f6
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatText.cs
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ /// An object describing expected output of the model as text.
+ public partial class AssistantsApiResponseFormatText : AssistantsApiResponseFormat
+ {
+ /// Initializes a new instance of .
+ public AssistantsApiResponseFormatText()
+ {
+ Type = Assistants.ApiResponseFormat?.Text;
+ }
+
+ /// Initializes a new instance of .
+ /// Must be one of `text`, `json_object` or `json_schema` .
+ /// Keeps track of any properties unknown to the library.
+ internal AssistantsApiResponseFormatText(ApiResponseFormat? type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData)
+ {
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiToolChoiceOptionMode.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiToolChoiceOptionMode.cs
new file mode 100644
index 000000000000..89f7812a7ae0
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiToolChoiceOptionMode.cs
@@ -0,0 +1,51 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.AI.OpenAI.Assistants
+{
+ /// Specifies how the tool choice will be used.
+ public readonly partial struct AssistantsApiToolChoiceOptionMode : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public AssistantsApiToolChoiceOptionMode(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string NoneValue = "none";
+ private const string AutoValue = "auto";
+
+ /// The model will not call a function and instead generates a message.
+ public static AssistantsApiToolChoiceOptionMode None { get; } = new AssistantsApiToolChoiceOptionMode(NoneValue);
+ /// The model can pick between generating a message or calling a function.
+ public static AssistantsApiToolChoiceOptionMode Auto { get; } = new AssistantsApiToolChoiceOptionMode(AutoValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(AssistantsApiToolChoiceOptionMode left, AssistantsApiToolChoiceOptionMode right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(AssistantsApiToolChoiceOptionMode left, AssistantsApiToolChoiceOptionMode right) => !left.Equals(right);
+ /// Converts a to a .
+ public static implicit operator AssistantsApiToolChoiceOptionMode(string value) => new AssistantsApiToolChoiceOptionMode(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is AssistantsApiToolChoiceOptionMode other && Equals(other);
+ ///
+ public bool Equals(AssistantsApiToolChoiceOptionMode 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;
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs
index b8455f85ccc2..e101178cbf3b 100644
--- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs
@@ -38,7 +38,7 @@ protected AssistantsClient()
}
/// Creates a new assistant.
- /// Body parameter.
+ /// The request details to use when creating a new assistant.
/// The cancellation token to use.
/// is null.
public virtual async Task> CreateAssistantAsync(AssistantCreationOptions body, CancellationToken cancellationToken = default)
@@ -52,7 +52,7 @@ public virtual async Task> CreateAssistantAsync(AssistantCre
}
/// Creates a new assistant.
- /// Body parameter.
+ /// The request details to use when creating a new assistant.
/// The cancellation token to use.
/// is null.
public virtual Response CreateAssistant(AssistantCreationOptions body, CancellationToken cancellationToken = default)
@@ -135,7 +135,7 @@ internal virtual Response CreateAssistant(RequestContent content, RequestContext
/// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
/// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
/// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
- /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
/// The cancellation token to use.
internal virtual async Task> InternalGetAssistantsAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
{
@@ -148,7 +148,7 @@ internal virtual async Task> Int
/// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
/// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
/// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
- /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
/// The cancellation token to use.
internal virtual Response InternalGetAssistants(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
{
@@ -175,7 +175,7 @@ internal virtual Response InternalGetAssi
/// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
/// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
/// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
- /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
/// Service returned a non-success status code.
/// The response returned from the service.
@@ -213,7 +213,7 @@ internal virtual async Task InternalGetAssistantsAsync(int? limit, str
/// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
/// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
/// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
- /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
/// Service returned a non-success status code.
/// The response returned from the service.
@@ -331,7 +331,7 @@ internal virtual Response GetAssistant(string assistantId, RequestContext contex
/// Modifies an existing assistant.
/// The ID of the assistant to modify.
- /// Body parameter.
+ /// The request details to use when modifying an existing assistant.
/// The cancellation token to use.
/// or is null.
/// is an empty string, and was expected to be non-empty.
@@ -348,7 +348,7 @@ public virtual async Task> UpdateAssistantAsync(string assis
/// Modifies an existing assistant.
/// The ID of the assistant to modify.
- /// Body parameter.
+ /// The request details to use when modifying an existing assistant.
/// The cancellation token to use.
/// or is null.
/// is an empty string, and was expected to be non-empty.
@@ -541,42 +541,36 @@ internal virtual Response InternalDeleteAssistant(string assistantId, RequestCon
}
}
- /// Attaches a previously uploaded file to an assistant for use by tools that can read files.
- /// The ID of the assistant to attach the file to.
- /// The ID of the previously uploaded file to attach.
+ /// Creates a new thread. Threads contain messages and can be run by assistants.
+ /// The details used to create a new assistant thread.
/// The cancellation token to use.
- /// or is null.
- /// is an empty string, and was expected to be non-empty.
- public virtual async Task> LinkAssistantFileAsync(string assistantId, string fileId, CancellationToken cancellationToken = default)
+ /// is null.
+ public virtual async Task> CreateThreadAsync(AssistantThreadCreationOptions body, CancellationToken cancellationToken = default)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
- Argument.AssertNotNull(fileId, nameof(fileId));
+ Argument.AssertNotNull(body, nameof(body));
- CreateAssistantFileRequest createAssistantFileRequest = new CreateAssistantFileRequest(fileId, null);
+ using RequestContent content = body.ToRequestContent();
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await LinkAssistantFileAsync(assistantId, createAssistantFileRequest.ToRequestContent(), context).ConfigureAwait(false);
- return Response.FromValue(AssistantFile.FromResponse(response), response);
+ Response response = await CreateThreadAsync(content, context).ConfigureAwait(false);
+ return Response.FromValue(AssistantThread.FromResponse(response), response);
}
- /// Attaches a previously uploaded file to an assistant for use by tools that can read files.
- /// The ID of the assistant to attach the file to.
- /// The ID of the previously uploaded file to attach.
+ /// Creates a new thread. Threads contain messages and can be run by assistants.
+ /// The details used to create a new assistant thread.
/// The cancellation token to use.
- /// or is null.
- /// is an empty string, and was expected to be non-empty.
- public virtual Response LinkAssistantFile(string assistantId, string fileId, CancellationToken cancellationToken = default)
+ /// is null.
+ public virtual Response CreateThread(AssistantThreadCreationOptions body, CancellationToken cancellationToken = default)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
- Argument.AssertNotNull(fileId, nameof(fileId));
+ Argument.AssertNotNull(body, nameof(body));
- CreateAssistantFileRequest createAssistantFileRequest = new CreateAssistantFileRequest(fileId, null);
+ using RequestContent content = body.ToRequestContent();
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = LinkAssistantFile(assistantId, createAssistantFileRequest.ToRequestContent(), context);
- return Response.FromValue(AssistantFile.FromResponse(response), response);
+ Response response = CreateThread(content, context);
+ return Response.FromValue(AssistantThread.FromResponse(response), response);
}
///
- /// [Protocol Method] Attaches a previously uploaded file to an assistant for use by tools that can read files.
+ /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by assistants.
///
/// -
///
@@ -585,23 +579,20 @@ public virtual Response LinkAssistantFile(string assistantId, str
///
///
///
- /// The ID of the assistant to attach the file to.
/// The content to send as the body of the request.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// or is null.
- /// is an empty string, and was expected to be non-empty.
+ /// is null.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual async Task LinkAssistantFileAsync(string assistantId, RequestContent content, RequestContext context = null)
+ internal virtual async Task CreateThreadAsync(RequestContent content, RequestContext context = null)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.LinkAssistantFile");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThread");
scope.Start();
try
{
- using HttpMessage message = CreateLinkAssistantFileRequest(assistantId, content, context);
+ using HttpMessage message = CreateCreateThreadRequest(content, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -612,7 +603,7 @@ internal virtual async Task LinkAssistantFileAsync(string assistantId,
}
///
- /// [Protocol Method] Attaches a previously uploaded file to an assistant for use by tools that can read files.
+ /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by assistants.
///
/// -
///
@@ -621,23 +612,20 @@ internal virtual async Task LinkAssistantFileAsync(string assistantId,
///
///
///
- /// The ID of the assistant to attach the file to.
/// The content to send as the body of the request.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// or is null.
- /// is an empty string, and was expected to be non-empty.
+ /// is null.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual Response LinkAssistantFile(string assistantId, RequestContent content, RequestContext context = null)
+ internal virtual Response CreateThread(RequestContent content, RequestContext context = null)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.LinkAssistantFile");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThread");
scope.Start();
try
{
- using HttpMessage message = CreateLinkAssistantFileRequest(assistantId, content, context);
+ using HttpMessage message = CreateCreateThreadRequest(content, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -647,76 +635,59 @@ internal virtual Response LinkAssistantFile(string assistantId, RequestContent c
}
}
- /// Gets a list of files attached to a specific assistant, as used by tools that can read files.
- /// The ID of the assistant to retrieve the list of attached files for.
- /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
- /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
- /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
- /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// Gets information about an existing thread.
+ /// The ID of the thread to retrieve information about.
/// The cancellation token to use.
- /// is null.
- /// is an empty string, and was expected to be non-empty.
- internal virtual async Task> InternalGetAssistantFilesAsync(string assistantId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual async Task> GetThreadAsync(string threadId, CancellationToken cancellationToken = default)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await InternalGetAssistantFilesAsync(assistantId, limit, order?.ToString(), after, before, context).ConfigureAwait(false);
- return Response.FromValue(InternalOpenAIPageableListOfAssistantFile.FromResponse(response), response);
+ Response response = await GetThreadAsync(threadId, context).ConfigureAwait(false);
+ return Response.FromValue(AssistantThread.FromResponse(response), response);
}
- /// Gets a list of files attached to a specific assistant, as used by tools that can read files.
- /// The ID of the assistant to retrieve the list of attached files for.
- /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
- /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
- /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
- /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// Gets information about an existing thread.
+ /// The ID of the thread to retrieve information about.
/// The cancellation token to use.
- /// is null.
- /// is an empty string, and was expected to be non-empty.
- internal virtual Response InternalGetAssistantFiles(string assistantId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual Response GetThread(string threadId, CancellationToken cancellationToken = default)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = InternalGetAssistantFiles(assistantId, limit, order?.ToString(), after, before, context);
- return Response.FromValue(InternalOpenAIPageableListOfAssistantFile.FromResponse(response), response);
+ Response response = GetThread(threadId, context);
+ return Response.FromValue(AssistantThread.FromResponse(response), response);
}
///
- /// [Protocol Method] Gets a list of files attached to a specific assistant, as used by tools that can read files.
+ /// [Protocol Method] Gets information about an existing thread.
///
/// -
///
/// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
///
///
- /// -
- ///
- /// Please try the simpler convenience overload with strongly typed models first.
- ///
- ///
///
///
- /// The ID of the assistant to retrieve the list of attached files for.
- /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
- /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
- /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
- /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The ID of the thread to retrieve information about.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// is null.
- /// is an empty string, and was expected to be non-empty.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual async Task InternalGetAssistantFilesAsync(string assistantId, int? limit, string order, string after, string before, RequestContext context)
+ internal virtual async Task GetThreadAsync(string threadId, RequestContext context)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetAssistantFiles");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetThread");
scope.Start();
try
{
- using HttpMessage message = CreateInternalGetAssistantFilesRequest(assistantId, limit, order, after, before, context);
+ using HttpMessage message = CreateGetThreadRequest(threadId, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -727,39 +698,30 @@ internal virtual async Task InternalGetAssistantFilesAsync(string assi
}
///
- /// [Protocol Method] Gets a list of files attached to a specific assistant, as used by tools that can read files.
+ /// [Protocol Method] Gets information about an existing thread.
///
/// -
///
/// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
///
///
- /// -
- ///
- /// Please try the simpler convenience overload with strongly typed models first.
- ///
- ///
///
///
- /// The ID of the assistant to retrieve the list of attached files for.
- /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
- /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
- /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
- /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
+ /// The ID of the thread to retrieve information about.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// is null.
- /// is an empty string, and was expected to be non-empty.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual Response InternalGetAssistantFiles(string assistantId, int? limit, string order, string after, string before, RequestContext context)
+ internal virtual Response GetThread(string threadId, RequestContext context)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetAssistantFiles");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetThread");
scope.Start();
try
{
- using HttpMessage message = CreateInternalGetAssistantFilesRequest(assistantId, limit, order, after, before, context);
+ using HttpMessage message = CreateGetThreadRequest(threadId, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -769,40 +731,42 @@ internal virtual Response InternalGetAssistantFiles(string assistantId, int? lim
}
}
- /// Retrieves a file attached to an assistant.
- /// The ID of the assistant associated with the attached file.
- /// The ID of the file to retrieve.
+ /// Modifies an existing thread.
+ /// The ID of the thread to modify.
+ /// The details used to update an existing assistant thread.
/// The cancellation token to use.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
- public virtual async Task> GetAssistantFileAsync(string assistantId, string fileId, CancellationToken cancellationToken = default)
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual async Task> UpdateThreadAsync(string threadId, UpdateAssistantThreadOptions body, CancellationToken cancellationToken = default)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
- Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNull(body, nameof(body));
+ using RequestContent content = body.ToRequestContent();
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await GetAssistantFileAsync(assistantId, fileId, context).ConfigureAwait(false);
- return Response.FromValue(AssistantFile.FromResponse(response), response);
+ Response response = await UpdateThreadAsync(threadId, content, context).ConfigureAwait(false);
+ return Response.FromValue(AssistantThread.FromResponse(response), response);
}
- /// Retrieves a file attached to an assistant.
- /// The ID of the assistant associated with the attached file.
- /// The ID of the file to retrieve.
+ /// Modifies an existing thread.
+ /// The ID of the thread to modify.
+ /// The details used to update an existing assistant thread.
/// The cancellation token to use.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
- public virtual Response GetAssistantFile(string assistantId, string fileId, CancellationToken cancellationToken = default)
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual Response UpdateThread(string threadId, UpdateAssistantThreadOptions body, CancellationToken cancellationToken = default)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
- Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNull(body, nameof(body));
+ using RequestContent content = body.ToRequestContent();
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = GetAssistantFile(assistantId, fileId, context);
- return Response.FromValue(AssistantFile.FromResponse(response), response);
+ Response response = UpdateThread(threadId, content, context);
+ return Response.FromValue(AssistantThread.FromResponse(response), response);
}
///
- /// [Protocol Method] Retrieves a file attached to an assistant.
+ /// [Protocol Method] Modifies an existing thread.
///
/// -
///
@@ -811,23 +775,23 @@ public virtual Response GetAssistantFile(string assistantId, stri
///
///
///
- /// The ID of the assistant associated with the attached file.
- /// The ID of the file to retrieve.
+ /// The ID of the thread to modify.
+ /// The content to send as the body of the request.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual async Task GetAssistantFileAsync(string assistantId, string fileId, RequestContext context)
+ internal virtual async Task UpdateThreadAsync(string threadId, RequestContent content, RequestContext context = null)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
- Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetAssistantFile");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateThread");
scope.Start();
try
{
- using HttpMessage message = CreateGetAssistantFileRequest(assistantId, fileId, context);
+ using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -838,7 +802,7 @@ internal virtual async Task GetAssistantFileAsync(string assistantId,
}
///
- /// [Protocol Method] Retrieves a file attached to an assistant.
+ /// [Protocol Method] Modifies an existing thread.
///
/// -
///
@@ -847,23 +811,23 @@ internal virtual async Task GetAssistantFileAsync(string assistantId,
///
///
///
- /// The ID of the assistant associated with the attached file.
- /// The ID of the file to retrieve.
+ /// The ID of the thread to modify.
+ /// The content to send as the body of the request.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual Response GetAssistantFile(string assistantId, string fileId, RequestContext context)
+ internal virtual Response UpdateThread(string threadId, RequestContent content, RequestContext context = null)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
- Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetAssistantFile");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateThread");
scope.Start();
try
{
- using HttpMessage message = CreateGetAssistantFileRequest(assistantId, fileId, context);
+ using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -873,47 +837,36 @@ internal virtual Response GetAssistantFile(string assistantId, string fileId, Re
}
}
- ///
- /// Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read
- /// files.
- ///
- /// The ID of the assistant from which the specified file should be unlinked.
- /// The ID of the file to unlink from the specified assistant.
+ /// Deletes an existing thread.
+ /// The ID of the thread to delete.
/// The cancellation token to use.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
- internal virtual async Task> InternalUnlinkAssistantFileAsync(string assistantId, string fileId, CancellationToken cancellationToken = default)
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ internal virtual async Task> InternalDeleteThreadAsync(string threadId, CancellationToken cancellationToken = default)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
- Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await InternalUnlinkAssistantFileAsync(assistantId, fileId, context).ConfigureAwait(false);
- return Response.FromValue(InternalAssistantFileDeletionStatus.FromResponse(response), response);
+ Response response = await InternalDeleteThreadAsync(threadId, context).ConfigureAwait(false);
+ return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response);
}
- ///
- /// Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read
- /// files.
- ///
- /// The ID of the assistant from which the specified file should be unlinked.
- /// The ID of the file to unlink from the specified assistant.
+ /// Deletes an existing thread.
+ /// The ID of the thread to delete.
/// The cancellation token to use.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
- internal virtual Response InternalUnlinkAssistantFile(string assistantId, string fileId, CancellationToken cancellationToken = default)
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ internal virtual Response InternalDeleteThread(string threadId, CancellationToken cancellationToken = default)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
- Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = InternalUnlinkAssistantFile(assistantId, fileId, context);
- return Response.FromValue(InternalAssistantFileDeletionStatus.FromResponse(response), response);
+ Response response = InternalDeleteThread(threadId, context);
+ return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response);
}
///
- /// [Protocol Method] Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read
- /// files.
+ /// [Protocol Method] Deletes an existing thread.
///
/// -
///
@@ -922,28 +875,26 @@ internal virtual Response InternalUnlinkAss
///
/// -
///
- /// Please try the simpler convenience overload with strongly typed models first.
+ /// Please try the simpler convenience overload with strongly typed models first.
///
///
///
///
- /// The ID of the assistant from which the specified file should be unlinked.
- /// The ID of the file to unlink from the specified assistant.
+ /// The ID of the thread to delete.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual async Task InternalUnlinkAssistantFileAsync(string assistantId, string fileId, RequestContext context)
+ internal virtual async Task InternalDeleteThreadAsync(string threadId, RequestContext context)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
- Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalUnlinkAssistantFile");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteThread");
scope.Start();
try
{
- using HttpMessage message = CreateInternalUnlinkAssistantFileRequest(assistantId, fileId, context);
+ using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -954,8 +905,7 @@ internal virtual async Task InternalUnlinkAssistantFileAsync(string as
}
///
- /// [Protocol Method] Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read
- /// files.
+ /// [Protocol Method] Deletes an existing thread.
///
/// -
///
@@ -964,28 +914,26 @@ internal virtual async Task InternalUnlinkAssistantFileAsync(string as
///
/// -
///
- /// Please try the simpler convenience overload with strongly typed models first.
+ /// Please try the simpler convenience overload with strongly typed models first.
///
///
///
///
- /// The ID of the assistant from which the specified file should be unlinked.
- /// The ID of the file to unlink from the specified assistant.
+ /// The ID of the thread to delete.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual Response InternalUnlinkAssistantFile(string assistantId, string fileId, RequestContext context)
+ internal virtual Response InternalDeleteThread(string threadId, RequestContext context)
{
- Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId));
- Argument.AssertNotNullOrEmpty(fileId, nameof(fileId));
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalUnlinkAssistantFile");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteThread");
scope.Start();
try
{
- using HttpMessage message = CreateInternalUnlinkAssistantFileRequest(assistantId, fileId, context);
+ using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -995,36 +943,42 @@ internal virtual Response InternalUnlinkAssistantFile(string assistantId, string
}
}
- /// Creates a new thread. Threads contain messages and can be run by assistants.
- /// Body parameter.
+ /// Creates a new message on a specified thread.
+ /// The ID of the thread to create the new message on.
+ /// A single message within an assistant thread, as provided during that thread's creation for its initial state.
/// The cancellation token to use.
- /// is null.
- public virtual async Task> CreateThreadAsync(AssistantThreadCreationOptions body, CancellationToken cancellationToken = default)
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual async Task> CreateMessageAsync(string threadId, ThreadMessageOptions body, CancellationToken cancellationToken = default)
{
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
Argument.AssertNotNull(body, nameof(body));
using RequestContent content = body.ToRequestContent();
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await CreateThreadAsync(content, context).ConfigureAwait(false);
- return Response.FromValue(AssistantThread.FromResponse(response), response);
+ Response response = await CreateMessageAsync(threadId, content, context).ConfigureAwait(false);
+ return Response.FromValue(ThreadMessage.FromResponse(response), response);
}
- /// Creates a new thread. Threads contain messages and can be run by assistants.
- /// Body parameter.
+ /// Creates a new message on a specified thread.
+ /// The ID of the thread to create the new message on.
+ /// A single message within an assistant thread, as provided during that thread's creation for its initial state.
/// The cancellation token to use.
- /// is null.
- public virtual Response CreateThread(AssistantThreadCreationOptions body, CancellationToken cancellationToken = default)
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual Response CreateMessage(string threadId, ThreadMessageOptions body, CancellationToken cancellationToken = default)
{
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
Argument.AssertNotNull(body, nameof(body));
using RequestContent content = body.ToRequestContent();
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = CreateThread(content, context);
- return Response.FromValue(AssistantThread.FromResponse(response), response);
+ Response response = CreateMessage(threadId, content, context);
+ return Response.FromValue(ThreadMessage.FromResponse(response), response);
}
///
- /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by assistants.
+ /// [Protocol Method] Creates a new message on a specified thread.
///
/// -
///
@@ -1033,20 +987,23 @@ public virtual Response CreateThread(AssistantThreadCreationOpt
///
///
///
+ /// The ID of the thread to create the new message on.
/// The content to send as the body of the request.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// is null.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual async Task CreateThreadAsync(RequestContent content, RequestContext context = null)
+ internal virtual async Task CreateMessageAsync(string threadId, RequestContent content, RequestContext context = null)
{
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThread");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateMessage");
scope.Start();
try
{
- using HttpMessage message = CreateCreateThreadRequest(content, context);
+ using HttpMessage message = CreateCreateMessageRequest(threadId, content, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -1057,7 +1014,7 @@ internal virtual async Task CreateThreadAsync(RequestContent content,
}
///
- /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by assistants.
+ /// [Protocol Method] Creates a new message on a specified thread.
///
/// -
///
@@ -1066,20 +1023,23 @@ internal virtual async Task CreateThreadAsync(RequestContent content,
///
///
///
+ /// The ID of the thread to create the new message on.
/// The content to send as the body of the request.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// is null.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual Response CreateThread(RequestContent content, RequestContext context = null)
+ internal virtual Response CreateMessage(string threadId, RequestContent content, RequestContext context = null)
{
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThread");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateMessage");
scope.Start();
try
{
- using HttpMessage message = CreateCreateThreadRequest(content, context);
+ using HttpMessage message = CreateCreateMessageRequest(threadId, content, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -1089,59 +1049,79 @@ internal virtual Response CreateThread(RequestContent content, RequestContext co
}
}
- /// Gets information about an existing thread.
- /// The ID of the thread to retrieve information about.
+ /// Gets a list of messages that exist on a thread.
+ /// The ID of the thread to list messages from.
+ /// Filter messages by the run ID that generated them.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
/// The cancellation token to use.
/// is null.
/// is an empty string, and was expected to be non-empty.
- public virtual async Task> GetThreadAsync(string threadId, CancellationToken cancellationToken = default)
+ internal virtual async Task> InternalGetMessagesAsync(string threadId, string runId = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await GetThreadAsync(threadId, context).ConfigureAwait(false);
- return Response.FromValue(AssistantThread.FromResponse(response), response);
+ Response response = await InternalGetMessagesAsync(threadId, runId, limit, order?.ToString(), after, before, context).ConfigureAwait(false);
+ return Response.FromValue(InternalOpenAIPageableListOfThreadMessage.FromResponse(response), response);
}
- /// Gets information about an existing thread.
- /// The ID of the thread to retrieve information about.
+ /// Gets a list of messages that exist on a thread.
+ /// The ID of the thread to list messages from.
+ /// Filter messages by the run ID that generated them.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
/// The cancellation token to use.
/// is null.
/// is an empty string, and was expected to be non-empty.
- public virtual Response GetThread(string threadId, CancellationToken cancellationToken = default)
+ internal virtual Response InternalGetMessages(string threadId, string runId = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = GetThread(threadId, context);
- return Response.FromValue(AssistantThread.FromResponse(response), response);
+ Response response = InternalGetMessages(threadId, runId, limit, order?.ToString(), after, before, context);
+ return Response.FromValue(InternalOpenAIPageableListOfThreadMessage.FromResponse(response), response);
}
///
- /// [Protocol Method] Gets information about an existing thread.
+ /// [Protocol Method] Gets a list of messages that exist on a thread.
///
/// -
///
/// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
///
///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
///
///
- /// The ID of the thread to retrieve information about.
+ /// The ID of the thread to list messages from.
+ /// Filter messages by the run ID that generated them.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
/// is null.
/// is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual async Task GetThreadAsync(string threadId, RequestContext context)
+ internal virtual async Task InternalGetMessagesAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetThread");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessages");
scope.Start();
try
{
- using HttpMessage message = CreateGetThreadRequest(threadId, context);
+ using HttpMessage message = CreateInternalGetMessagesRequest(threadId, runId, limit, order, after, before, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -1152,30 +1132,40 @@ internal virtual async Task GetThreadAsync(string threadId, RequestCon
}
///
- /// [Protocol Method] Gets information about an existing thread.
+ /// [Protocol Method] Gets a list of messages that exist on a thread.
///
/// -
///
/// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
///
///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
///
///
- /// The ID of the thread to retrieve information about.
+ /// The ID of the thread to list messages from.
+ /// Filter messages by the run ID that generated them.
+ /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
+ /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc".
+ /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
+ /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
/// is null.
/// is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual Response GetThread(string threadId, RequestContext context)
+ internal virtual Response InternalGetMessages(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetThread");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessages");
scope.Start();
try
{
- using HttpMessage message = CreateGetThreadRequest(threadId, context);
+ using HttpMessage message = CreateInternalGetMessagesRequest(threadId, runId, limit, order, after, before, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -1185,40 +1175,40 @@ internal virtual Response GetThread(string threadId, RequestContext context)
}
}
- /// Modifies an existing thread.
- /// The ID of the thread to modify.
- /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// Gets an existing message from an existing thread.
+ /// The ID of the thread to retrieve the specified message from.
+ /// The ID of the message to retrieve from the specified thread.
/// The cancellation token to use.
- /// is null.
- /// is an empty string, and was expected to be non-empty.
- public virtual async Task> UpdateThreadAsync(string threadId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual async Task> GetMessageAsync(string threadId, string messageId, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
- UpdateThreadRequest updateThreadRequest = new UpdateThreadRequest(metadata ?? new ChangeTrackingDictionary(), null);
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await UpdateThreadAsync(threadId, updateThreadRequest.ToRequestContent(), context).ConfigureAwait(false);
- return Response.FromValue(AssistantThread.FromResponse(response), response);
+ Response response = await GetMessageAsync(threadId, messageId, context).ConfigureAwait(false);
+ return Response.FromValue(ThreadMessage.FromResponse(response), response);
}
- /// Modifies an existing thread.
- /// The ID of the thread to modify.
- /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// Gets an existing message from an existing thread.
+ /// The ID of the thread to retrieve the specified message from.
+ /// The ID of the message to retrieve from the specified thread.
/// The cancellation token to use.
- /// is null.
- /// is an empty string, and was expected to be non-empty.
- public virtual Response UpdateThread(string threadId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual Response GetMessage(string threadId, string messageId, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
- UpdateThreadRequest updateThreadRequest = new UpdateThreadRequest(metadata ?? new ChangeTrackingDictionary(), null);
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = UpdateThread(threadId, updateThreadRequest.ToRequestContent(), context);
- return Response.FromValue(AssistantThread.FromResponse(response), response);
+ Response response = GetMessage(threadId, messageId, context);
+ return Response.FromValue(ThreadMessage.FromResponse(response), response);
}
///
- /// [Protocol Method] Modifies an existing thread.
+ /// [Protocol Method] Gets an existing message from an existing thread.
///
/// -
///
@@ -1227,23 +1217,23 @@ public virtual Response UpdateThread(string threadId, IReadOnly
///
///
///
- /// The ID of the thread to modify.
- /// The content to send as the body of the request.
+ /// The ID of the thread to retrieve the specified message from.
+ /// The ID of the message to retrieve from the specified thread.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// or is null.
- /// is an empty string, and was expected to be non-empty.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual async Task UpdateThreadAsync(string threadId, RequestContent content, RequestContext context = null)
+ internal virtual async Task GetMessageAsync(string threadId, string messageId, RequestContext context)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNull(content, nameof(content));
+ Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateThread");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessage");
scope.Start();
try
{
- using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context);
+ using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -1254,7 +1244,7 @@ internal virtual async Task UpdateThreadAsync(string threadId, Request
}
///
- /// [Protocol Method] Modifies an existing thread.
+ /// [Protocol Method] Gets an existing message from an existing thread.
///
/// -
///
@@ -1263,23 +1253,23 @@ internal virtual async Task UpdateThreadAsync(string threadId, Request
///
///
///
- /// The ID of the thread to modify.
- /// The content to send as the body of the request.
+ /// The ID of the thread to retrieve the specified message from.
+ /// The ID of the message to retrieve from the specified thread.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// or is null.
- /// is an empty string, and was expected to be non-empty.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual Response UpdateThread(string threadId, RequestContent content, RequestContext context = null)
+ internal virtual Response GetMessage(string threadId, string messageId, RequestContext context)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNull(content, nameof(content));
+ Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateThread");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessage");
scope.Start();
try
{
- using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context);
+ using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -1289,64 +1279,71 @@ internal virtual Response UpdateThread(string threadId, RequestContent content,
}
}
- /// Deletes an existing thread.
- /// The ID of the thread to delete.
+ /// Modifies an existing message on an existing thread.
+ /// The ID of the thread containing the specified message to modify.
+ /// The ID of the message to modify on the specified thread.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
/// The cancellation token to use.
- /// is null.
- /// is an empty string, and was expected to be non-empty.
- internal virtual async Task> InternalDeleteThreadAsync(string threadId, CancellationToken cancellationToken = default)
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual async Task> UpdateMessageAsync(string threadId, string messageId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null);
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await InternalDeleteThreadAsync(threadId, context).ConfigureAwait(false);
- return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response);
+ Response response = await UpdateMessageAsync(threadId, messageId, updateMessageRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(ThreadMessage.FromResponse(response), response);
}
- /// Deletes an existing thread.
- /// The ID of the thread to delete.
+ /// Modifies an existing message on an existing thread.
+ /// The ID of the thread containing the specified message to modify.
+ /// The ID of the message to modify on the specified thread.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
/// The cancellation token to use.
- /// is null.
- /// is an empty string, and was expected to be non-empty.
- internal virtual Response InternalDeleteThread(string threadId, CancellationToken cancellationToken = default)
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual Response UpdateMessage(string threadId, string messageId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null);
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = InternalDeleteThread(threadId, context);
- return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response);
+ Response response = UpdateMessage(threadId, messageId, updateMessageRequest.ToRequestContent(), context);
+ return Response.FromValue(ThreadMessage.FromResponse(response), response);
}
///
- /// [Protocol Method] Deletes an existing thread.
+ /// [Protocol Method] Modifies an existing message on an existing thread.
///
/// -
///
/// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
///
///
- /// -
- ///
- /// Please try the simpler convenience overload with strongly typed models first.
- ///
- ///
///
///
- /// The ID of the thread to delete.
+ /// The ID of the thread containing the specified message to modify.
+ /// The ID of the message to modify on the specified thread.
+ /// The content to send as the body of the request.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// is null.
- /// is an empty string, and was expected to be non-empty.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual async Task InternalDeleteThreadAsync(string threadId, RequestContext context)
+ internal virtual async Task UpdateMessageAsync(string threadId, string messageId, RequestContent content, RequestContext context = null)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteThread");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateMessage");
scope.Start();
try
{
- using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context);
+ using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -1357,35 +1354,34 @@ internal virtual async Task InternalDeleteThreadAsync(string threadId,
}
///
- /// [Protocol Method] Deletes an existing thread.
+ /// [Protocol Method] Modifies an existing message on an existing thread.
///
/// -
///
/// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
///
///
- /// -
- ///
- /// Please try the simpler convenience overload with strongly typed models first.
- ///
- ///
///
///
- /// The ID of the thread to delete.
+ /// The ID of the thread containing the specified message to modify.
+ /// The ID of the message to modify on the specified thread.
+ /// The content to send as the body of the request.
/// The request context, which can override default behaviors of the client pipeline on a per-call basis.
- /// is null.
- /// is an empty string, and was expected to be non-empty.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual Response InternalDeleteThread(string threadId, RequestContext context)
+ internal virtual Response UpdateMessage(string threadId, string messageId, RequestContent content, RequestContext context = null)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteThread");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateMessage");
scope.Start();
try
{
- using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context);
+ using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -1395,48 +1391,44 @@ internal virtual Response InternalDeleteThread(string threadId, RequestContext c
}
}
- /// Creates a new message on a specified thread.
- /// The ID of the thread to create the new message on.
- /// The role to associate with the new message.
- /// The textual content for the new message.
- /// A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files.
- /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// Creates a new run for an assistant thread.
+ /// The ID of the thread to run.
+ /// The details used when creating a new run of an assistant thread.
+ /// A list of additional fields to include in the response.
/// The cancellation token to use.
- /// or is null.
+ /// or is null.
/// is an empty string, and was expected to be non-empty.
- public virtual async Task> CreateMessageAsync(string threadId, MessageRole role, string content, IEnumerable fileIds = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ public virtual async Task> CreateRunAsync(string threadId, CreateRunOptions body, IEnumerable runInclude = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNull(content, nameof(content));
+ Argument.AssertNotNull(body, nameof(body));
- CreateMessageRequest createMessageRequest = new CreateMessageRequest(role, content, fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), null);
+ using RequestContent content = body.ToRequestContent();
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await CreateMessageAsync(threadId, createMessageRequest.ToRequestContent(), context).ConfigureAwait(false);
- return Response.FromValue(ThreadMessage.FromResponse(response), response);
+ Response response = await CreateRunAsync(threadId, content, runInclude, context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
}
- /// Creates a new message on a specified thread.
- /// The ID of the thread to create the new message on.
- /// The role to associate with the new message.
- /// The textual content for the new message.
- /// A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files.
- /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// Creates a new run for an assistant thread.
+ /// The ID of the thread to run.
+ /// The details used when creating a new run of an assistant thread.
+ /// A list of additional fields to include in the response.
/// The cancellation token to use.
- /// or is null.
+ /// or is null.
/// is an empty string, and was expected to be non-empty.
- public virtual Response CreateMessage(string threadId, MessageRole role, string content, IEnumerable fileIds = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ public virtual Response CreateRun(string threadId, CreateRunOptions body, IEnumerable runInclude = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNull(content, nameof(content));
+ Argument.AssertNotNull(body, nameof(body));
- CreateMessageRequest createMessageRequest = new CreateMessageRequest(role, content, fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), null);
+ using RequestContent content = body.ToRequestContent();
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = CreateMessage(threadId, createMessageRequest.ToRequestContent(), context);
- return Response.FromValue(ThreadMessage.FromResponse(response), response);
+ Response response = CreateRun(threadId, content, runInclude, context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
}
///
- /// [Protocol Method] Creates a new message on a specified thread.
+ /// [Protocol Method] Creates a new run for an assistant thread.
///