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..b2bd551420ac
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ApiResponseFormat.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
+{
+ /// Possible API response formats.
+ public 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";
+
+ /// `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);
+ /// 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 7f7c124b0054..de33b338f1ec 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
@@ -68,13 +68,52 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions
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))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ else
+ {
+ writer.WriteNull("response_format");
+ }
}
- writer.WriteEndArray();
if (Metadata != null && Optional.IsCollectionDefined(Metadata))
{
writer.WritePropertyName("metadata"u8);
@@ -136,7 +175,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();
@@ -202,14 +244,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))
@@ -242,7 +314,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 28455a04d327..c906e565aced 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
@@ -74,15 +74,60 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead
}
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))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ else
+ {
+ writer.WriteNull("response_format");
}
- writer.WriteEndArray();
}
if (Optional.IsCollectionDefined(Metadata))
{
@@ -145,7 +190,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();
@@ -200,18 +248,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))
@@ -240,7 +314,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 72793c7f2950..550ab46b2be4 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
@@ -32,6 +32,15 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO
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);
@@ -88,6 +97,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();
@@ -108,6 +118,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)
@@ -129,7 +149,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 ffd998161e30..873de1490d7f 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
@@ -36,6 +36,18 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod
}
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)
@@ -92,7 +104,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();
@@ -104,14 +117,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)
@@ -132,7 +155,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..c1cc832cf7b1
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.Serialization.cs
@@ -0,0 +1,142 @@
+// 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 AssistantsApiResponseFormat : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(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.");
+ }
+
+ writer.WriteStartObject();
+ 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))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ writer.WriteEndObject();
+ }
+
+ 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;
+ }
+ 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 AssistantsApiResponseFormat(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(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);
+ 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);
+ 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/src/Generated/AzureOpenAIChatErrorResponse.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.cs
similarity index 61%
rename from sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatErrorResponse.cs
rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.cs
index 767fce2b029e..02f2e275e525 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatErrorResponse.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
//
#nullable disable
@@ -5,10 +8,13 @@
using System;
using System.Collections.Generic;
-namespace Azure.AI.OpenAI
+namespace Azure.AI.OpenAI.Assistants
{
- /// A structured representation of an error an Azure OpenAI request.
- internal partial class AzureOpenAIChatErrorResponse
+ ///
+ /// 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.
+ ///
+ public partial class AssistantsApiResponseFormat
{
///
/// Keeps track of any properties unknown to the library.
@@ -40,22 +46,23 @@ internal partial class AzureOpenAIChatErrorResponse
///
///
///
- internal IDictionary SerializedAdditionalRawData { get; set; }
- /// Initializes a new instance of .
- internal AzureOpenAIChatErrorResponse()
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ public AssistantsApiResponseFormat()
{
}
- /// Initializes a new instance of .
- ///
+ /// Initializes a new instance of .
+ /// Must be one of `text` or `json_object`.
/// Keeps track of any properties unknown to the library.
- internal AzureOpenAIChatErrorResponse(AzureOpenAIChatError error, IDictionary serializedAdditionalRawData)
+ internal AssistantsApiResponseFormat(ApiResponseFormat? type, IDictionary serializedAdditionalRawData)
{
- Error = error;
- SerializedAdditionalRawData = serializedAdditionalRawData;
+ Type = type;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
}
- /// Gets the error.
- public AzureOpenAIChatError Error { get; }
+ /// Must be one of `text` or `json_object`.
+ public ApiResponseFormat? Type { 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..1dac794d9529
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatMode.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
+{
+ /// 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";
+ private const string NoneValue = "none";
+
+ /// Default value. Let the model handle the return format.
+ public static AssistantsApiResponseFormatMode Auto { get; } = new AssistantsApiResponseFormatMode(AutoValue);
+ /// Setting the value to `none`, will result in a 400 Bad request.
+ public static AssistantsApiResponseFormatMode None { get; } = new AssistantsApiResponseFormatMode(NoneValue);
+ /// 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/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 c85db38a83b6..996e52afcb6e 100644
--- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs
+++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs
@@ -39,7 +39,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)
@@ -53,7 +53,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)
@@ -332,7 +332,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.
@@ -349,7 +349,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.
@@ -542,42 +542,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.
///
/// -
///
@@ -586,23 +580,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)
@@ -613,7 +604,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.
///
/// -
///
@@ -622,23 +613,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)
@@ -648,76 +636,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)
@@ -728,39 +699,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)
@@ -770,40 +732,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.
///
/// -
///
@@ -812,23 +776,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)
@@ -839,7 +803,7 @@ internal virtual async Task GetAssistantFileAsync(string assistantId,
}
///
- /// [Protocol Method] Retrieves a file attached to an assistant.
+ /// [Protocol Method] Modifies an existing thread.
///
/// -
///
@@ -848,23 +812,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)
@@ -874,47 +838,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.
///
/// -
///
@@ -923,28 +876,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)
@@ -955,8 +906,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.
///
/// -
///
@@ -965,28 +915,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)
@@ -996,36 +944,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.
///
/// -
///
@@ -1034,20 +988,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)
@@ -1058,7 +1015,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.
///
/// -
///
@@ -1067,20 +1024,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)
@@ -1090,59 +1050,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, ending 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, ending 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, ending 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)
@@ -1153,30 +1133,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, ending 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)
@@ -1186,40 +1176,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.
///
/// -
///
@@ -1228,23 +1218,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)
@@ -1255,7 +1245,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.
///
/// -
///
@@ -1264,23 +1254,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)
@@ -1290,64 +1280,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)
@@ -1358,35 +1355,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)
@@ -1396,48 +1392,42 @@ 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.
/// 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, 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, 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.
/// 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, 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, 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.
///
/// -
///
@@ -1446,23 +1436,23 @@ public virtual Response CreateMessage(string threadId, MessageRol
///
///
///
- /// The ID of the thread to create the new message on.
+ /// The ID of the thread to run.
/// 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.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual async Task CreateMessageAsync(string threadId, RequestContent content, RequestContext context = null)
+ internal virtual async Task CreateRunAsync(string threadId, RequestContent content, RequestContext context = null)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateMessage");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateRun");
scope.Start();
try
{
- using HttpMessage message = CreateCreateMessageRequest(threadId, content, context);
+ using HttpMessage message = CreateCreateRunRequest(threadId, content, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -1473,7 +1463,7 @@ internal virtual async Task CreateMessageAsync(string threadId, Reques
}
///
- /// [Protocol Method] Creates a new message on a specified thread.
+ /// [Protocol Method] Creates a new run for an assistant thread.
///
/// -
///
@@ -1482,23 +1472,23 @@ internal virtual async Task CreateMessageAsync(string threadId, Reques
///
///
///
- /// The ID of the thread to create the new message on.
+ /// The ID of the thread to run.
/// 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.
/// Service returned a non-success status code.
/// The response returned from the service.
- internal virtual Response CreateMessage(string threadId, RequestContent content, RequestContext context = null)
+ internal virtual Response CreateRun(string threadId, RequestContent content, RequestContext context = null)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateMessage");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateRun");
scope.Start();
try
{
- using HttpMessage message = CreateCreateMessageRequest(threadId, content, context);
+ using HttpMessage message = CreateCreateRunRequest(threadId, content, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -1508,8 +1498,8 @@ internal virtual Response CreateMessage(string threadId, RequestContent content,
}
}
- /// Gets a list of messages that exist on a thread.
- /// The ID of the thread to list messages from.
+ /// Gets a list of runs for a specified thread.
+ /// The ID of the thread to list runs from.
/// 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.
@@ -1517,17 +1507,17 @@ internal virtual Response CreateMessage(string threadId, RequestContent content,
/// The cancellation token to use.
/// is null.
/// is an empty string, and was expected to be non-empty.
- internal virtual async Task> InternalGetMessagesAsync(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ internal virtual async Task> InternalGetRunsAsync(string threadId, 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 InternalGetMessagesAsync(threadId, limit, order?.ToString(), after, before, context).ConfigureAwait(false);
- return Response.FromValue(InternalOpenAIPageableListOfThreadMessage.FromResponse(response), response);
+ Response response = await InternalGetRunsAsync(threadId, limit, order?.ToString(), after, before, context).ConfigureAwait(false);
+ return Response.FromValue(InternalOpenAIPageableListOfThreadRun.FromResponse(response), response);
}
- /// Gets a list of messages that exist on a thread.
- /// The ID of the thread to list messages from.
+ /// Gets a list of runs for a specified thread.
+ /// The ID of the thread to list runs from.
/// 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.
@@ -1535,17 +1525,17 @@ internal virtual async Task>
/// The cancellation token to use.
/// is null.
/// is an empty string, and was expected to be non-empty.
- internal virtual Response InternalGetMessages(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ internal virtual Response InternalGetRuns(string threadId, 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 = InternalGetMessages(threadId, limit, order?.ToString(), after, before, context);
- return Response.FromValue(InternalOpenAIPageableListOfThreadMessage.FromResponse(response), response);
+ Response response = InternalGetRuns(threadId, limit, order?.ToString(), after, before, context);
+ return Response.FromValue(InternalOpenAIPageableListOfThreadRun.FromResponse(response), response);
}
///
- /// [Protocol Method] Gets a list of messages that exist on a thread.
+ /// [Protocol Method] Gets a list of runs for a specified thread.
///
/// -
///
@@ -1554,12 +1544,12 @@ internal virtual Response InternalGet
///
/// -
///
- /// 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 thread to list messages from.
+ /// The ID of the thread to list runs from.
/// 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.
@@ -1569,15 +1559,15 @@ internal virtual Response InternalGet
/// 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 InternalGetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestContext context)
+ internal virtual async Task InternalGetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestContext context)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessages");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRuns");
scope.Start();
try
{
- using HttpMessage message = CreateInternalGetMessagesRequest(threadId, limit, order, after, before, context);
+ using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -1588,7 +1578,7 @@ internal virtual async Task InternalGetMessagesAsync(string threadId,
}
///
- /// [Protocol Method] Gets a list of messages that exist on a thread.
+ /// [Protocol Method] Gets a list of runs for a specified thread.
///
/// -
///
@@ -1597,12 +1587,12 @@ internal virtual async Task InternalGetMessagesAsync(string threadId,
///
/// -
///
- /// 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 thread to list messages from.
+ /// The ID of the thread to list runs from.
/// 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.
@@ -1612,15 +1602,15 @@ internal virtual async Task InternalGetMessagesAsync(string threadId,
/// 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 InternalGetMessages(string threadId, int? limit, string order, string after, string before, RequestContext context)
+ internal virtual Response InternalGetRuns(string threadId, int? limit, string order, string after, string before, RequestContext context)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessages");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRuns");
scope.Start();
try
{
- using HttpMessage message = CreateInternalGetMessagesRequest(threadId, limit, order, after, before, context);
+ using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -1630,40 +1620,40 @@ internal virtual Response InternalGetMessages(string threadId, int? limit, strin
}
}
- /// 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.
+ /// Gets an existing run from an existing thread.
+ /// The ID of the thread to retrieve run information from.
+ /// The ID of the thread to retrieve information about.
/// The cancellation token to use.
- /// 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)
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual async Task> GetRunAsync(string threadId, string runId, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await GetMessageAsync(threadId, messageId, context).ConfigureAwait(false);
- return Response.FromValue(ThreadMessage.FromResponse(response), response);
+ Response response = await GetRunAsync(threadId, runId, context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
}
- /// 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.
+ /// Gets an existing run from an existing thread.
+ /// The ID of the thread to retrieve run information from.
+ /// The ID of the thread to retrieve information about.
/// The cancellation token to use.
- /// 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)
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual Response GetRun(string threadId, string runId, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = GetMessage(threadId, messageId, context);
- return Response.FromValue(ThreadMessage.FromResponse(response), response);
+ Response response = GetRun(threadId, runId, context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
}
///
- /// [Protocol Method] Gets an existing message from an existing thread.
+ /// [Protocol Method] Gets an existing run from an existing thread.
///
/// -
///
@@ -1672,23 +1662,23 @@ public virtual Response GetMessage(string threadId, string messag
///
///
///
- /// The ID of the thread to retrieve the specified message from.
- /// The ID of the message to retrieve from the specified thread.
+ /// The ID of the thread to retrieve run information from.
+ /// 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.
- /// or is null.
- /// or 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 GetMessageAsync(string threadId, string messageId, RequestContext context)
+ internal virtual async Task GetRunAsync(string threadId, string runId, RequestContext context)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessage");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRun");
scope.Start();
try
{
- using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context);
+ using HttpMessage message = CreateGetRunRequest(threadId, runId, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -1699,7 +1689,7 @@ internal virtual async Task GetMessageAsync(string threadId, string me
}
///
- /// [Protocol Method] Gets an existing message from an existing thread.
+ /// [Protocol Method] Gets an existing run from an existing thread.
///
/// -
///
@@ -1708,23 +1698,23 @@ internal virtual async Task GetMessageAsync(string threadId, string me
///
///
///
- /// The ID of the thread to retrieve the specified message from.
- /// The ID of the message to retrieve from the specified thread.
+ /// The ID of the thread to retrieve run information from.
+ /// 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.
- /// or is null.
- /// or 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 GetMessage(string threadId, string messageId, RequestContext context)
+ internal virtual Response GetRun(string threadId, string runId, RequestContext context)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessage");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRun");
scope.Start();
try
{
- using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context);
+ using HttpMessage message = CreateGetRunRequest(threadId, runId, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -1734,44 +1724,44 @@ internal virtual Response GetMessage(string threadId, string messageId, RequestC
}
}
- /// 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.
+ /// Modifies an existing thread run.
+ /// The ID of the thread associated with the specified run.
+ /// The ID of the run 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.
/// The cancellation token to use.
- /// 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)
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual async Task> UpdateRunAsync(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
- UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null);
+ UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null);
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await UpdateMessageAsync(threadId, messageId, updateMessageRequest.ToRequestContent(), context).ConfigureAwait(false);
- return Response.FromValue(ThreadMessage.FromResponse(response), response);
+ Response response = await UpdateRunAsync(threadId, runId, updateRunRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
}
- /// 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.
+ /// Modifies an existing thread run.
+ /// The ID of the thread associated with the specified run.
+ /// The ID of the run 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.
/// The cancellation token to use.
- /// 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)
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual Response UpdateRun(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
- UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null);
+ UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null);
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = UpdateMessage(threadId, messageId, updateMessageRequest.ToRequestContent(), context);
- return Response.FromValue(ThreadMessage.FromResponse(response), response);
+ Response response = UpdateRun(threadId, runId, updateRunRequest.ToRequestContent(), context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
}
///
- /// [Protocol Method] Modifies an existing message on an existing thread.
+ /// [Protocol Method] Modifies an existing thread run.
///
/// -
///
@@ -1780,25 +1770,25 @@ public virtual Response UpdateMessage(string threadId, string mes
///
///
///
- /// The ID of the thread containing the specified message to modify.
- /// The ID of the message to modify on the specified thread.
+ /// The ID of the thread associated with the specified run.
+ /// The ID of the run 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.
+ /// 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 UpdateMessageAsync(string threadId, string messageId, RequestContent content, RequestContext context = null)
+ internal virtual async Task UpdateRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateMessage");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateRun");
scope.Start();
try
{
- using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context);
+ using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context);
return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
}
catch (Exception e)
@@ -1809,7 +1799,7 @@ internal virtual async Task UpdateMessageAsync(string threadId, string
}
///
- /// [Protocol Method] Modifies an existing message on an existing thread.
+ /// [Protocol Method] Modifies an existing thread run.
///
/// -
///
@@ -1818,25 +1808,25 @@ internal virtual async Task UpdateMessageAsync(string threadId, string
///
///
///
- /// The ID of the thread containing the specified message to modify.
- /// The ID of the message to modify on the specified thread.
+ /// The ID of the thread associated with the specified run.
+ /// The ID of the run 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.
+ /// 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 UpdateMessage(string threadId, string messageId, RequestContent content, RequestContext context = null)
+ internal virtual Response UpdateRun(string threadId, string runId, RequestContent content, RequestContext context = null)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateMessage");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateRun");
scope.Start();
try
{
- using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context);
+ using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context);
return _pipeline.ProcessMessage(message, context);
}
catch (Exception e)
@@ -1846,82 +1836,812 @@ internal virtual Response UpdateMessage(string threadId, string messageId, Reque
}
}
- /// Gets a list of previously uploaded files associated with a message from a thread.
- /// The ID of the thread containing the message to list files from.
- /// The ID of the message to list files from.
- /// 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.
+ /// Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'.
+ /// The ID of the thread that was run.
+ /// The ID of the run that requires tool outputs.
+ /// A list of tools for which the outputs are being submitted.
+ /// If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.
/// The cancellation token to use.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
- internal virtual async Task> InternalGetMessageFilesAsync(string threadId, string messageId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual async Task> SubmitToolOutputsToRunAsync(string threadId, string runId, IEnumerable toolOutputs, bool? stream = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNull(toolOutputs, nameof(toolOutputs));
+ SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList(), stream, null);
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = await InternalGetMessageFilesAsync(threadId, messageId, limit, order?.ToString(), after, before, context).ConfigureAwait(false);
- return Response.FromValue(InternalOpenAIPageableListOfMessageFile.FromResponse(response), response);
+ Response response = await SubmitToolOutputsToRunAsync(threadId, runId, submitToolOutputsToRunRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
}
- /// Gets a list of previously uploaded files associated with a message from a thread.
- /// The ID of the thread containing the message to list files from.
- /// The ID of the message to list files from.
- /// 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.
+ /// Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'.
+ /// The ID of the thread that was run.
+ /// The ID of the run that requires tool outputs.
+ /// A list of tools for which the outputs are being submitted.
+ /// If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.
/// The cancellation token to use.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
- internal virtual Response InternalGetMessageFiles(string threadId, string messageId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual Response SubmitToolOutputsToRun(string threadId, string runId, IEnumerable toolOutputs, bool? stream = null, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNull(toolOutputs, nameof(toolOutputs));
+ SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList(), stream, null);
RequestContext context = FromCancellationToken(cancellationToken);
- Response response = InternalGetMessageFiles(threadId, messageId, limit, order?.ToString(), after, before, context);
- return Response.FromValue(InternalOpenAIPageableListOfMessageFile.FromResponse(response), response);
+ Response response = SubmitToolOutputsToRun(threadId, runId, submitToolOutputsToRunRequest.ToRequestContent(), context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
}
///
- /// [Protocol Method] Gets a list of previously uploaded files associated with a message from a thread.
+ /// [Protocol Method] Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'.
///
/// -
///
/// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
///
///
+ ///
+ ///
+ /// The ID of the thread that was run.
+ /// The ID of the run that requires tool outputs.
+ /// 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.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task SubmitToolOutputsToRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.SubmitToolOutputsToRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'.
+ ///
/// -
///
- /// Please try the simpler convenience overload with strongly typed models first.
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
///
///
///
///
- /// The ID of the thread containing the message to list files from.
- /// The ID of the message to list files from.
- /// 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 that was run.
+ /// The ID of the run that requires tool outputs.
+ /// 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.
+ /// 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 InternalGetMessageFilesAsync(string threadId, string messageId, int? limit, string order, string after, string before, RequestContext context)
+ internal virtual Response SubmitToolOutputsToRun(string threadId, string runId, RequestContent content, RequestContext context = null)
{
Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
- Argument.AssertNotNullOrEmpty(messageId, nameof(messageId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNull(content, nameof(content));
- using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessageFiles");
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.SubmitToolOutputsToRun");
scope.Start();
try
{
- using HttpMessage message = CreateInternalGetMessageFilesRequest(threadId, messageId, limit, order, after, before, context);
+ using HttpMessage message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Cancels a run of an in progress thread.
+ /// The ID of the thread being run.
+ /// The ID of the run to cancel.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual async Task> CancelRunAsync(string threadId, string runId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await CancelRunAsync(threadId, runId, context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ /// Cancels a run of an in progress thread.
+ /// The ID of the thread being run.
+ /// The ID of the run to cancel.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ public virtual Response CancelRun(string threadId, string runId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = CancelRun(threadId, runId, context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Cancels a run of an in progress thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// The ID of the thread being run.
+ /// The ID of the run to cancel.
+ /// 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.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task CancelRunAsync(string threadId, string runId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CancelRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCancelRunRequest(threadId, runId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Cancels a run of an in progress thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// The ID of the thread being run.
+ /// The ID of the run to cancel.
+ /// 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.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual Response CancelRun(string threadId, string runId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CancelRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCancelRunRequest(threadId, runId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Creates a new assistant thread and immediately starts a run using that new thread.
+ /// The details used when creating and immediately running a new assistant thread.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual async Task> CreateThreadAndRunAsync(CreateAndRunThreadOptions body, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(body, nameof(body));
+
+ using RequestContent content = body.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await CreateThreadAndRunAsync(content, context).ConfigureAwait(false);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ /// Creates a new assistant thread and immediately starts a run using that new thread.
+ /// The details used when creating and immediately running a new assistant thread.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual Response CreateThreadAndRun(CreateAndRunThreadOptions body, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(body, nameof(body));
+
+ using RequestContent content = body.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = CreateThreadAndRun(content, context);
+ return Response.FromValue(ThreadRun.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Creates a new assistant thread and immediately starts a run using that new thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// 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.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task CreateThreadAndRunAsync(RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThreadAndRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateThreadAndRunRequest(content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Creates a new assistant thread and immediately starts a run using that new thread.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// 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.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual Response CreateThreadAndRun(RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThreadAndRun");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateCreateThreadAndRunRequest(content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Gets a single run step from a thread run.
+ /// The ID of the thread that was run.
+ /// The ID of the specific run to retrieve the step from.
+ /// The ID of the step to retrieve information about.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ public virtual async Task> GetRunStepAsync(string threadId, string runId, string stepId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNullOrEmpty(stepId, nameof(stepId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await GetRunStepAsync(threadId, runId, stepId, context).ConfigureAwait(false);
+ return Response.FromValue(RunStep.FromResponse(response), response);
+ }
+
+ /// Gets a single run step from a thread run.
+ /// The ID of the thread that was run.
+ /// The ID of the specific run to retrieve the step from.
+ /// The ID of the step to retrieve information about.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ public virtual Response GetRunStep(string threadId, string runId, string stepId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNullOrEmpty(stepId, nameof(stepId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = GetRunStep(threadId, runId, stepId, context);
+ return Response.FromValue(RunStep.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Gets a single run step from a thread run.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// The ID of the thread that was run.
+ /// The ID of the specific run to retrieve the step from.
+ /// The ID of the step to retrieve information about.
+ /// 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.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task GetRunStepAsync(string threadId, string runId, string stepId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNullOrEmpty(stepId, nameof(stepId));
+
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRunStep");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Gets a single run step from a thread run.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// The ID of the thread that was run.
+ /// The ID of the specific run to retrieve the step from.
+ /// The ID of the step to retrieve information about.
+ /// 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.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual Response GetRunStep(string threadId, string runId, string stepId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+ Argument.AssertNotNullOrEmpty(stepId, nameof(stepId));
+
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRunStep");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Gets a list of run steps from a thread run.
+ /// The ID of the thread that was run.
+ /// The ID of the run to list steps from.
+ /// 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.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual async Task> InternalGetRunStepsAsync(string threadId, string runId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await InternalGetRunStepsAsync(threadId, runId, limit, order?.ToString(), after, before, context).ConfigureAwait(false);
+ return Response.FromValue(InternalOpenAIPageableListOfRunStep.FromResponse(response), response);
+ }
+
+ /// Gets a list of run steps from a thread run.
+ /// The ID of the thread that was run.
+ /// The ID of the run to list steps from.
+ /// 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.
+ /// The cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual Response InternalGetRunSteps(string threadId, string runId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = InternalGetRunSteps(threadId, runId, limit, order?.ToString(), after, before, context);
+ return Response.FromValue(InternalOpenAIPageableListOfRunStep.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Gets a list of run steps from a thread run.
+ ///
+ /// -
+ ///
+ /// 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 that was run.
+ /// The ID of the run to list steps from.
+ /// 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 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.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task InternalGetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRunSteps");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, limit, order, after, before, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Gets a list of run steps from a thread run.
+ ///
+ /// -
+ ///
+ /// 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 that was run.
+ /// The ID of the run to list steps from.
+ /// 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 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.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual Response InternalGetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(threadId, nameof(threadId));
+ Argument.AssertNotNullOrEmpty(runId, nameof(runId));
+
+ using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRunSteps");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, limit, order, after, before, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Gets a list of previously uploaded files.
+ /// A value that, when provided, limits list results to files matching the corresponding purpose.
+ /// The cancellation token to use.
+ internal virtual async Task> InternalListFilesAsync(OpenAIFilePurpose? purpose = null, CancellationToken cancellationToken = default)
+ {
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await InternalListFilesAsync(purpose?.ToString(), context).ConfigureAwait(false);
+ return Response.FromValue(InternalFileListResponse.FromResponse(response), response);
+ }
+
+ /// Gets a list of previously uploaded files.
+ /// A value that, when provided, limits list results to files matching the corresponding purpose.
+ /// The cancellation token to use.
+ internal virtual Response InternalListFiles(OpenAIFilePurpose? purpose = null, CancellationToken cancellationToken = default)
+ {
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = InternalListFiles(purpose?.ToString(), context);
+ return Response.FromValue(InternalFileListResponse.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Gets a list of previously uploaded files.
+ ///
+ /// -
+ ///