diff --git a/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.net8.0.cs b/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.net8.0.cs index 7f2bbc1c6f92..d2f5723951f2 100644 --- a/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.net8.0.cs +++ b/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.net8.0.cs @@ -193,9 +193,9 @@ public AgentsClient(System.Uri endpoint, string subscriptionId, string resourceG public virtual Azure.Response CreateAgent(string model, string name = null, string description = null, string instructions = null, System.Collections.Generic.IEnumerable tools = null, Azure.AI.Projects.ToolResources toolResources = null, float? temperature = default(float?), float? topP = default(float?), System.BinaryData responseFormat = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task CreateAgentAsync(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } public virtual System.Threading.Tasks.Task> CreateAgentAsync(string model, string name = null, string description = null, string instructions = null, System.Collections.Generic.IEnumerable tools = null, Azure.AI.Projects.ToolResources toolResources = null, float? temperature = default(float?), float? topP = default(float?), System.BinaryData responseFormat = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response CreateMessage(string threadId, Azure.AI.Projects.MessageRole role, string content, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response CreateMessage(string threadId, Azure.AI.Projects.MessageRole role, System.BinaryData content, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response CreateMessage(string threadId, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } - public virtual System.Threading.Tasks.Task> CreateMessageAsync(string threadId, Azure.AI.Projects.MessageRole role, string content, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateMessageAsync(string threadId, Azure.AI.Projects.MessageRole role, System.BinaryData content, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task CreateMessageAsync(string threadId, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } public virtual Azure.Response CreateRun(Azure.AI.Projects.AgentThread thread, Azure.AI.Projects.Agent agent, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response CreateRun(string threadId, Azure.Core.RequestContent content, System.Collections.Generic.IEnumerable include = null, Azure.RequestContext context = null) { throw null; } @@ -279,6 +279,10 @@ public AgentsClient(System.Uri endpoint, string subscriptionId, string resourceG public virtual Azure.Response GetThread(string threadId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task GetThreadAsync(string threadId, Azure.RequestContext context) { throw null; } public virtual System.Threading.Tasks.Task> GetThreadAsync(string threadId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetThreads(int? limit = default(int?), Azure.AI.Projects.ListSortOrder? order = default(Azure.AI.Projects.ListSortOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetThreads(int? limit, string order, string after, string before, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetThreadsAsync(int? limit = default(int?), Azure.AI.Projects.ListSortOrder? order = default(Azure.AI.Projects.ListSortOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetThreadsAsync(int? limit, string order, string after, string before, Azure.RequestContext context) { throw null; } public virtual Azure.Response GetVectorStore(string vectorStoreId, Azure.RequestContext context) { throw null; } public virtual Azure.Response GetVectorStore(string vectorStoreId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task GetVectorStoreAsync(string vectorStoreId, Azure.RequestContext context) { throw null; } @@ -513,10 +517,16 @@ public static partial class AIProjectsModelFactory public static Azure.AI.Projects.MessageDeltaTextFilePathAnnotationObject MessageDeltaTextFilePathAnnotationObject(string fileId = null) { throw null; } public static Azure.AI.Projects.MessageDeltaTextUrlCitationAnnotation MessageDeltaTextUrlCitationAnnotation(int index = 0, Azure.AI.Projects.MessageDeltaTextUrlCitationDetails urlCitation = null, int? startIndex = default(int?), int? endIndex = default(int?)) { throw null; } public static Azure.AI.Projects.MessageDeltaTextUrlCitationDetails MessageDeltaTextUrlCitationDetails(string url = null, string title = null) { throw null; } + public static Azure.AI.Projects.MessageImageFileParam MessageImageFileParam(string fileId = null, Azure.AI.Projects.ImageDetailLevel? detail = default(Azure.AI.Projects.ImageDetailLevel?)) { throw null; } + public static Azure.AI.Projects.MessageImageUrlParam MessageImageUrlParam(string url = null, Azure.AI.Projects.ImageDetailLevel? detail = default(Azure.AI.Projects.ImageDetailLevel?)) { throw null; } public static Azure.AI.Projects.MessageIncompleteDetails MessageIncompleteDetails(Azure.AI.Projects.MessageIncompleteDetailsReason reason = default(Azure.AI.Projects.MessageIncompleteDetailsReason)) { throw null; } + public static Azure.AI.Projects.MessageInputImageFileBlock MessageInputImageFileBlock(Azure.AI.Projects.MessageImageFileParam imageFile = null) { throw null; } + public static Azure.AI.Projects.MessageInputImageUrlBlock MessageInputImageUrlBlock(Azure.AI.Projects.MessageImageUrlParam imageUrl = null) { throw null; } + public static Azure.AI.Projects.MessageInputTextBlock MessageInputTextBlock(string text = null) { throw null; } public static Azure.AI.Projects.MessageTextAnnotation MessageTextAnnotation(string type = null, string text = null) { throw null; } public static Azure.AI.Projects.MessageTextUrlCitationAnnotation MessageTextUrlCitationAnnotation(string text = null, Azure.AI.Projects.MessageTextUrlCitationDetails urlCitation = null, int? startIndex = default(int?), int? endIndex = default(int?)) { throw null; } public static Azure.AI.Projects.MessageTextUrlCitationDetails MessageTextUrlCitationDetails(string url = null, string title = null) { throw null; } + public static Azure.AI.Projects.OpenAIPageableListOfAgentThread OpenAIPageableListOfAgentThread(Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject @object = default(Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject), System.Collections.Generic.IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = false) { throw null; } public static Azure.AI.Projects.RequiredToolCall RequiredToolCall(string type = null, string id = null) { throw null; } public static Azure.AI.Projects.ResponseFormatJsonSchemaType ResponseFormatJsonSchemaType(Azure.AI.Projects.ResponseFormatJsonSchemaTypeType type = default(Azure.AI.Projects.ResponseFormatJsonSchemaTypeType), Azure.AI.Projects.ResponseFormatJsonSchema jsonSchema = null) { throw null; } public static Azure.AI.Projects.RunCompletionUsage RunCompletionUsage(long completionTokens = (long)0, long promptTokens = (long)0, long totalTokens = (long)0) { throw null; } @@ -555,7 +565,7 @@ public static partial class AIProjectsModelFactory public static Azure.AI.Projects.RunStepToolCall RunStepToolCall(string type = null, string id = null) { throw null; } public static Azure.AI.Projects.RunStepToolCallDetails RunStepToolCallDetails(System.Collections.Generic.IEnumerable toolCalls = null) { throw null; } public static Azure.AI.Projects.SystemData SystemData(System.DateTimeOffset? createdAt = default(System.DateTimeOffset?), string createdBy = null, string createdByType = null, System.DateTimeOffset? lastModifiedAt = default(System.DateTimeOffset?)) { throw null; } - public static Azure.AI.Projects.ThreadMessageOptions ThreadMessageOptions(Azure.AI.Projects.MessageRole role = default(Azure.AI.Projects.MessageRole), string content = null, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IDictionary metadata = null) { throw null; } + public static Azure.AI.Projects.ThreadMessageOptions ThreadMessageOptions(Azure.AI.Projects.MessageRole role = default(Azure.AI.Projects.MessageRole), System.BinaryData content = null, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IDictionary metadata = null) { throw null; } public static Azure.AI.Projects.VectorStore VectorStore(string id = null, Azure.AI.Projects.VectorStoreObject @object = default(Azure.AI.Projects.VectorStoreObject), System.DateTimeOffset createdAt = default(System.DateTimeOffset), string name = null, int usageBytes = 0, Azure.AI.Projects.VectorStoreFileCount fileCounts = null, Azure.AI.Projects.VectorStoreStatus status = default(Azure.AI.Projects.VectorStoreStatus), Azure.AI.Projects.VectorStoreExpirationPolicy expiresAfter = null, System.DateTimeOffset? expiresAt = default(System.DateTimeOffset?), System.DateTimeOffset? lastActiveAt = default(System.DateTimeOffset?), System.Collections.Generic.IReadOnlyDictionary metadata = null) { throw null; } public static Azure.AI.Projects.VectorStoreDeletionStatus VectorStoreDeletionStatus(string id = null, bool deleted = false, Azure.AI.Projects.VectorStoreDeletionStatusObject @object = default(Azure.AI.Projects.VectorStoreDeletionStatusObject)) { throw null; } public static Azure.AI.Projects.VectorStoreFile VectorStoreFile(string id = null, Azure.AI.Projects.VectorStoreFileObject @object = default(Azure.AI.Projects.VectorStoreFileObject), int usageBytes = 0, System.DateTimeOffset createdAt = default(System.DateTimeOffset), string vectorStoreId = null, Azure.AI.Projects.VectorStoreFileStatus status = default(Azure.AI.Projects.VectorStoreFileStatus), Azure.AI.Projects.VectorStoreFileError lastError = null, Azure.AI.Projects.VectorStoreChunkingStrategyResponse chunkingStrategy = null) { throw null; } @@ -1188,6 +1198,25 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ImageDetailLevel : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ImageDetailLevel(string value) { throw null; } + public static Azure.AI.Projects.ImageDetailLevel Auto { get { throw null; } } + public static Azure.AI.Projects.ImageDetailLevel High { get { throw null; } } + public static Azure.AI.Projects.ImageDetailLevel Low { get { throw null; } } + public bool Equals(Azure.AI.Projects.ImageDetailLevel other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.ImageDetailLevel left, Azure.AI.Projects.ImageDetailLevel right) { throw null; } + public static implicit operator Azure.AI.Projects.ImageDetailLevel (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.ImageDetailLevel left, Azure.AI.Projects.ImageDetailLevel right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct IncompleteDetailsReason : System.IEquatable { private readonly object _dummy; @@ -1519,6 +1548,30 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class MessageImageFileParam : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MessageImageFileParam(string fileId) { } + public Azure.AI.Projects.ImageDetailLevel? Detail { get { throw null; } set { } } + public string FileId { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageImageFileParam System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageImageFileParam System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MessageImageUrlParam : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MessageImageUrlParam(string url) { } + public Azure.AI.Projects.ImageDetailLevel? Detail { get { throw null; } set { } } + public string Url { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageImageUrlParam System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageImageUrlParam System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class MessageIncompleteDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal MessageIncompleteDetails() { } @@ -1551,6 +1604,49 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public static bool operator !=(Azure.AI.Projects.MessageIncompleteDetailsReason left, Azure.AI.Projects.MessageIncompleteDetailsReason right) { throw null; } public override string ToString() { throw null; } } + public abstract partial class MessageInputContentBlock : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + protected MessageInputContentBlock() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputContentBlock System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputContentBlock System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MessageInputImageFileBlock : Azure.AI.Projects.MessageInputContentBlock, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MessageInputImageFileBlock(Azure.AI.Projects.MessageImageFileParam imageFile) { } + public Azure.AI.Projects.MessageImageFileParam ImageFile { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputImageFileBlock System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputImageFileBlock System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MessageInputImageUrlBlock : Azure.AI.Projects.MessageInputContentBlock, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MessageInputImageUrlBlock(Azure.AI.Projects.MessageImageUrlParam imageUrl) { } + public Azure.AI.Projects.MessageImageUrlParam ImageUrl { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputImageUrlBlock System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputImageUrlBlock System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MessageInputTextBlock : Azure.AI.Projects.MessageInputContentBlock, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MessageInputTextBlock(string text) { } + public string Text { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputTextBlock System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputTextBlock System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct MessageRole : System.IEquatable { @@ -1699,6 +1795,38 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class OpenAIPageableListOfAgentThread : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal OpenAIPageableListOfAgentThread() { } + public System.Collections.Generic.IReadOnlyList Data { get { throw null; } } + public string FirstId { get { throw null; } } + public bool HasMore { get { throw null; } } + public string LastId { get { throw null; } } + public Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject Object { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAIPageableListOfAgentThread System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAIPageableListOfAgentThread System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct OpenAIPageableListOfAgentThreadObject : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public OpenAIPageableListOfAgentThreadObject(string value) { throw null; } + public static Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject List { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject left, Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject left, Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject right) { throw null; } + public override string ToString() { throw null; } + } public partial class OpenApiAnonymousAuthDetails : Azure.AI.Projects.OpenApiAuthDetails, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public OpenApiAnonymousAuthDetails() { } @@ -2751,9 +2879,9 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer } public partial class ThreadMessageOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public ThreadMessageOptions(Azure.AI.Projects.MessageRole role, string content) { } + public ThreadMessageOptions(Azure.AI.Projects.MessageRole role, System.BinaryData content) { } public System.Collections.Generic.IList Attachments { get { throw null; } set { } } - public string Content { get { throw null; } } + public System.BinaryData Content { get { throw null; } } public System.Collections.Generic.IDictionary Metadata { get { throw null; } set { } } public Azure.AI.Projects.MessageRole Role { get { throw null; } } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } diff --git a/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.netstandard2.0.cs b/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.netstandard2.0.cs index 7f2bbc1c6f92..d2f5723951f2 100644 --- a/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.netstandard2.0.cs +++ b/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.netstandard2.0.cs @@ -193,9 +193,9 @@ public AgentsClient(System.Uri endpoint, string subscriptionId, string resourceG public virtual Azure.Response CreateAgent(string model, string name = null, string description = null, string instructions = null, System.Collections.Generic.IEnumerable tools = null, Azure.AI.Projects.ToolResources toolResources = null, float? temperature = default(float?), float? topP = default(float?), System.BinaryData responseFormat = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task CreateAgentAsync(Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } public virtual System.Threading.Tasks.Task> CreateAgentAsync(string model, string name = null, string description = null, string instructions = null, System.Collections.Generic.IEnumerable tools = null, Azure.AI.Projects.ToolResources toolResources = null, float? temperature = default(float?), float? topP = default(float?), System.BinaryData responseFormat = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response CreateMessage(string threadId, Azure.AI.Projects.MessageRole role, string content, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response CreateMessage(string threadId, Azure.AI.Projects.MessageRole role, System.BinaryData content, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response CreateMessage(string threadId, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } - public virtual System.Threading.Tasks.Task> CreateMessageAsync(string threadId, Azure.AI.Projects.MessageRole role, string content, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateMessageAsync(string threadId, Azure.AI.Projects.MessageRole role, System.BinaryData content, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task CreateMessageAsync(string threadId, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } public virtual Azure.Response CreateRun(Azure.AI.Projects.AgentThread thread, Azure.AI.Projects.Agent agent, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response CreateRun(string threadId, Azure.Core.RequestContent content, System.Collections.Generic.IEnumerable include = null, Azure.RequestContext context = null) { throw null; } @@ -279,6 +279,10 @@ public AgentsClient(System.Uri endpoint, string subscriptionId, string resourceG public virtual Azure.Response GetThread(string threadId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task GetThreadAsync(string threadId, Azure.RequestContext context) { throw null; } public virtual System.Threading.Tasks.Task> GetThreadAsync(string threadId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetThreads(int? limit = default(int?), Azure.AI.Projects.ListSortOrder? order = default(Azure.AI.Projects.ListSortOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetThreads(int? limit, string order, string after, string before, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task> GetThreadsAsync(int? limit = default(int?), Azure.AI.Projects.ListSortOrder? order = default(Azure.AI.Projects.ListSortOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetThreadsAsync(int? limit, string order, string after, string before, Azure.RequestContext context) { throw null; } public virtual Azure.Response GetVectorStore(string vectorStoreId, Azure.RequestContext context) { throw null; } public virtual Azure.Response GetVectorStore(string vectorStoreId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task GetVectorStoreAsync(string vectorStoreId, Azure.RequestContext context) { throw null; } @@ -513,10 +517,16 @@ public static partial class AIProjectsModelFactory public static Azure.AI.Projects.MessageDeltaTextFilePathAnnotationObject MessageDeltaTextFilePathAnnotationObject(string fileId = null) { throw null; } public static Azure.AI.Projects.MessageDeltaTextUrlCitationAnnotation MessageDeltaTextUrlCitationAnnotation(int index = 0, Azure.AI.Projects.MessageDeltaTextUrlCitationDetails urlCitation = null, int? startIndex = default(int?), int? endIndex = default(int?)) { throw null; } public static Azure.AI.Projects.MessageDeltaTextUrlCitationDetails MessageDeltaTextUrlCitationDetails(string url = null, string title = null) { throw null; } + public static Azure.AI.Projects.MessageImageFileParam MessageImageFileParam(string fileId = null, Azure.AI.Projects.ImageDetailLevel? detail = default(Azure.AI.Projects.ImageDetailLevel?)) { throw null; } + public static Azure.AI.Projects.MessageImageUrlParam MessageImageUrlParam(string url = null, Azure.AI.Projects.ImageDetailLevel? detail = default(Azure.AI.Projects.ImageDetailLevel?)) { throw null; } public static Azure.AI.Projects.MessageIncompleteDetails MessageIncompleteDetails(Azure.AI.Projects.MessageIncompleteDetailsReason reason = default(Azure.AI.Projects.MessageIncompleteDetailsReason)) { throw null; } + public static Azure.AI.Projects.MessageInputImageFileBlock MessageInputImageFileBlock(Azure.AI.Projects.MessageImageFileParam imageFile = null) { throw null; } + public static Azure.AI.Projects.MessageInputImageUrlBlock MessageInputImageUrlBlock(Azure.AI.Projects.MessageImageUrlParam imageUrl = null) { throw null; } + public static Azure.AI.Projects.MessageInputTextBlock MessageInputTextBlock(string text = null) { throw null; } public static Azure.AI.Projects.MessageTextAnnotation MessageTextAnnotation(string type = null, string text = null) { throw null; } public static Azure.AI.Projects.MessageTextUrlCitationAnnotation MessageTextUrlCitationAnnotation(string text = null, Azure.AI.Projects.MessageTextUrlCitationDetails urlCitation = null, int? startIndex = default(int?), int? endIndex = default(int?)) { throw null; } public static Azure.AI.Projects.MessageTextUrlCitationDetails MessageTextUrlCitationDetails(string url = null, string title = null) { throw null; } + public static Azure.AI.Projects.OpenAIPageableListOfAgentThread OpenAIPageableListOfAgentThread(Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject @object = default(Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject), System.Collections.Generic.IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = false) { throw null; } public static Azure.AI.Projects.RequiredToolCall RequiredToolCall(string type = null, string id = null) { throw null; } public static Azure.AI.Projects.ResponseFormatJsonSchemaType ResponseFormatJsonSchemaType(Azure.AI.Projects.ResponseFormatJsonSchemaTypeType type = default(Azure.AI.Projects.ResponseFormatJsonSchemaTypeType), Azure.AI.Projects.ResponseFormatJsonSchema jsonSchema = null) { throw null; } public static Azure.AI.Projects.RunCompletionUsage RunCompletionUsage(long completionTokens = (long)0, long promptTokens = (long)0, long totalTokens = (long)0) { throw null; } @@ -555,7 +565,7 @@ public static partial class AIProjectsModelFactory public static Azure.AI.Projects.RunStepToolCall RunStepToolCall(string type = null, string id = null) { throw null; } public static Azure.AI.Projects.RunStepToolCallDetails RunStepToolCallDetails(System.Collections.Generic.IEnumerable toolCalls = null) { throw null; } public static Azure.AI.Projects.SystemData SystemData(System.DateTimeOffset? createdAt = default(System.DateTimeOffset?), string createdBy = null, string createdByType = null, System.DateTimeOffset? lastModifiedAt = default(System.DateTimeOffset?)) { throw null; } - public static Azure.AI.Projects.ThreadMessageOptions ThreadMessageOptions(Azure.AI.Projects.MessageRole role = default(Azure.AI.Projects.MessageRole), string content = null, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IDictionary metadata = null) { throw null; } + public static Azure.AI.Projects.ThreadMessageOptions ThreadMessageOptions(Azure.AI.Projects.MessageRole role = default(Azure.AI.Projects.MessageRole), System.BinaryData content = null, System.Collections.Generic.IEnumerable attachments = null, System.Collections.Generic.IDictionary metadata = null) { throw null; } public static Azure.AI.Projects.VectorStore VectorStore(string id = null, Azure.AI.Projects.VectorStoreObject @object = default(Azure.AI.Projects.VectorStoreObject), System.DateTimeOffset createdAt = default(System.DateTimeOffset), string name = null, int usageBytes = 0, Azure.AI.Projects.VectorStoreFileCount fileCounts = null, Azure.AI.Projects.VectorStoreStatus status = default(Azure.AI.Projects.VectorStoreStatus), Azure.AI.Projects.VectorStoreExpirationPolicy expiresAfter = null, System.DateTimeOffset? expiresAt = default(System.DateTimeOffset?), System.DateTimeOffset? lastActiveAt = default(System.DateTimeOffset?), System.Collections.Generic.IReadOnlyDictionary metadata = null) { throw null; } public static Azure.AI.Projects.VectorStoreDeletionStatus VectorStoreDeletionStatus(string id = null, bool deleted = false, Azure.AI.Projects.VectorStoreDeletionStatusObject @object = default(Azure.AI.Projects.VectorStoreDeletionStatusObject)) { throw null; } public static Azure.AI.Projects.VectorStoreFile VectorStoreFile(string id = null, Azure.AI.Projects.VectorStoreFileObject @object = default(Azure.AI.Projects.VectorStoreFileObject), int usageBytes = 0, System.DateTimeOffset createdAt = default(System.DateTimeOffset), string vectorStoreId = null, Azure.AI.Projects.VectorStoreFileStatus status = default(Azure.AI.Projects.VectorStoreFileStatus), Azure.AI.Projects.VectorStoreFileError lastError = null, Azure.AI.Projects.VectorStoreChunkingStrategyResponse chunkingStrategy = null) { throw null; } @@ -1188,6 +1198,25 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ImageDetailLevel : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ImageDetailLevel(string value) { throw null; } + public static Azure.AI.Projects.ImageDetailLevel Auto { get { throw null; } } + public static Azure.AI.Projects.ImageDetailLevel High { get { throw null; } } + public static Azure.AI.Projects.ImageDetailLevel Low { get { throw null; } } + public bool Equals(Azure.AI.Projects.ImageDetailLevel other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.ImageDetailLevel left, Azure.AI.Projects.ImageDetailLevel right) { throw null; } + public static implicit operator Azure.AI.Projects.ImageDetailLevel (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.ImageDetailLevel left, Azure.AI.Projects.ImageDetailLevel right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct IncompleteDetailsReason : System.IEquatable { private readonly object _dummy; @@ -1519,6 +1548,30 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class MessageImageFileParam : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MessageImageFileParam(string fileId) { } + public Azure.AI.Projects.ImageDetailLevel? Detail { get { throw null; } set { } } + public string FileId { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageImageFileParam System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageImageFileParam System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MessageImageUrlParam : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MessageImageUrlParam(string url) { } + public Azure.AI.Projects.ImageDetailLevel? Detail { get { throw null; } set { } } + public string Url { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageImageUrlParam System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageImageUrlParam System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class MessageIncompleteDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal MessageIncompleteDetails() { } @@ -1551,6 +1604,49 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public static bool operator !=(Azure.AI.Projects.MessageIncompleteDetailsReason left, Azure.AI.Projects.MessageIncompleteDetailsReason right) { throw null; } public override string ToString() { throw null; } } + public abstract partial class MessageInputContentBlock : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + protected MessageInputContentBlock() { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputContentBlock System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputContentBlock System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MessageInputImageFileBlock : Azure.AI.Projects.MessageInputContentBlock, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MessageInputImageFileBlock(Azure.AI.Projects.MessageImageFileParam imageFile) { } + public Azure.AI.Projects.MessageImageFileParam ImageFile { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputImageFileBlock System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputImageFileBlock System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MessageInputImageUrlBlock : Azure.AI.Projects.MessageInputContentBlock, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MessageInputImageUrlBlock(Azure.AI.Projects.MessageImageUrlParam imageUrl) { } + public Azure.AI.Projects.MessageImageUrlParam ImageUrl { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputImageUrlBlock System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputImageUrlBlock System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MessageInputTextBlock : Azure.AI.Projects.MessageInputContentBlock, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MessageInputTextBlock(string text) { } + public string Text { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputTextBlock System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MessageInputTextBlock System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct MessageRole : System.IEquatable { @@ -1699,6 +1795,38 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class OpenAIPageableListOfAgentThread : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal OpenAIPageableListOfAgentThread() { } + public System.Collections.Generic.IReadOnlyList Data { get { throw null; } } + public string FirstId { get { throw null; } } + public bool HasMore { get { throw null; } } + public string LastId { get { throw null; } } + public Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject Object { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAIPageableListOfAgentThread System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAIPageableListOfAgentThread System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct OpenAIPageableListOfAgentThreadObject : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public OpenAIPageableListOfAgentThreadObject(string value) { throw null; } + public static Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject List { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject left, Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject left, Azure.AI.Projects.OpenAIPageableListOfAgentThreadObject right) { throw null; } + public override string ToString() { throw null; } + } public partial class OpenApiAnonymousAuthDetails : Azure.AI.Projects.OpenApiAuthDetails, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public OpenApiAnonymousAuthDetails() { } @@ -2751,9 +2879,9 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer } public partial class ThreadMessageOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public ThreadMessageOptions(Azure.AI.Projects.MessageRole role, string content) { } + public ThreadMessageOptions(Azure.AI.Projects.MessageRole role, System.BinaryData content) { } public System.Collections.Generic.IList Attachments { get { throw null; } set { } } - public string Content { get { throw null; } } + public System.BinaryData Content { get { throw null; } } public System.Collections.Generic.IDictionary Metadata { get { throw null; } set { } } public Azure.AI.Projects.MessageRole Role { get { throw null; } } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs index 46d572c1ea33..bf1e6302ee50 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs @@ -35,20 +35,20 @@ public static ResponseFormatJsonSchemaType ResponseFormatJsonSchemaType(Response /// Initializes a new instance of . /// /// The role of the entity that is creating the message. Allowed values include: - /// - `user`: Indicates the message is sent by an actual user and should be used in most - /// cases to represent user-generated messages. - /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert - /// messages from the agent into the - /// conversation. + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). /// /// - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via - /// a separate call to the create message API. + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). /// /// A list of files attached to the message, and the tools they should be added to. /// 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. /// A new instance for mocking. - public static ThreadMessageOptions ThreadMessageOptions(MessageRole role = default, string content = null, IEnumerable attachments = null, IDictionary metadata = null) + public static ThreadMessageOptions ThreadMessageOptions(MessageRole role = default, BinaryData content = null, IEnumerable attachments = null, IDictionary metadata = null) { attachments ??= new List(); metadata ??= new Dictionary(); @@ -56,6 +56,68 @@ public static ThreadMessageOptions ThreadMessageOptions(MessageRole role = defau return new ThreadMessageOptions(role, content, attachments?.ToList(), metadata, serializedAdditionalRawData: null); } + /// Initializes a new instance of . + /// The plain text content for this block. + /// A new instance for mocking. + public static MessageInputTextBlock MessageInputTextBlock(string text = null) + { + return new MessageInputTextBlock(MessageBlockType.Text, serializedAdditionalRawData: null, text); + } + + /// Initializes a new instance of . + /// Information about the referenced image file, including file ID and optional detail level. + /// A new instance for mocking. + public static MessageInputImageFileBlock MessageInputImageFileBlock(MessageImageFileParam imageFile = null) + { + return new MessageInputImageFileBlock(MessageBlockType.ImageFile, serializedAdditionalRawData: null, imageFile); + } + + /// Initializes a new instance of . + /// The ID of the previously uploaded image file. + /// Optional detail level for the image (auto, low, or high). + /// A new instance for mocking. + public static MessageImageFileParam MessageImageFileParam(string fileId = null, ImageDetailLevel? detail = null) + { + return new MessageImageFileParam(fileId, detail, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Information about the external image URL, including the URL and optional detail level. + /// A new instance for mocking. + public static MessageInputImageUrlBlock MessageInputImageUrlBlock(MessageImageUrlParam imageUrl = null) + { + return new MessageInputImageUrlBlock(MessageBlockType.ImageUrl, serializedAdditionalRawData: null, imageUrl); + } + + /// Initializes a new instance of . + /// The publicly accessible URL of the external image. + /// Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. + /// A new instance for mocking. + public static MessageImageUrlParam MessageImageUrlParam(string url = null, ImageDetailLevel? detail = null) + { + return new MessageImageUrlParam(url, detail, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// A new instance for mocking. + public static OpenAIPageableListOfAgentThread OpenAIPageableListOfAgentThread(OpenAIPageableListOfAgentThreadObject @object = default, IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = default) + { + data ??= new List(); + + return new OpenAIPageableListOfAgentThread( + @object, + data?.ToList(), + firstId, + lastId, + hasMore, + serializedAdditionalRawData: null); + } + /// Initializes a new instance of . /// The provided reason describing why the message was marked as incomplete. /// A new instance for mocking. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.cs index b226cfb94368..1983a0c90b7b 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.cs @@ -14,7 +14,7 @@ namespace Azure.AI.Projects public partial class AOAIModelConfig : TargetModelConfig { /// Initializes a new instance of . - /// Endpoint URL for AOAI model. + /// Endpoint targetURI for AOAI model. /// API Key for AOAI model. /// Deployment name for AOAI model. /// , or is null. @@ -33,7 +33,7 @@ public AOAIModelConfig(string azureEndpoint, string apiKey, string azureDeployme /// Initializes a new instance of . /// Type of the model configuration. /// Keeps track of any properties unknown to the library. - /// Endpoint URL for AOAI model. + /// Endpoint targetURI for AOAI model. /// API Key for AOAI model. /// Deployment name for AOAI model. internal AOAIModelConfig(string type, IDictionary serializedAdditionalRawData, string azureEndpoint, string apiKey, string azureDeployment) : base(type, serializedAdditionalRawData) @@ -48,7 +48,7 @@ internal AOAIModelConfig() { } - /// Endpoint URL for AOAI model. + /// Endpoint targetURI for AOAI model. public string AzureEndpoint { get; set; } /// API Key for AOAI model. public string ApiKey { get; set; } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentsClient.cs index 28e26de41003..a569c5e82c59 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsClient.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentsClient.cs @@ -1162,26 +1162,128 @@ internal virtual Response InternalDeleteThread(string threadId, RequestContext c } } + /// Gets a list of threads that were previously created. + /// 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. + public virtual async Task> GetThreadsAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetThreadsAsync(limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfAgentThread.FromResponse(response), response); + } + + /// Gets a list of threads that were previously created. + /// 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. + public virtual Response GetThreads(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetThreads(limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfAgentThread.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of threads that were previously created. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// 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. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetThreadsAsync(int? limit, string order, string after, string before, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetThreads"); + scope.Start(); + try + { + using HttpMessage message = CreateGetThreadsRequest(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 threads that were previously created. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// 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. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual Response GetThreads(int? limit, string order, string after, string before, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("AgentsClient.GetThreads"); + scope.Start(); + try + { + using HttpMessage message = CreateGetThreadsRequest(limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + /// Creates a new message on a specified thread. /// Identifier of the thread. /// /// The role of the entity that is creating the message. Allowed values include: - /// - `user`: Indicates the message is sent by an actual user and should be used in most - /// cases to represent user-generated messages. - /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert - /// messages from the agent into the - /// conversation. + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). /// /// - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via - /// a separate call to the create message API. + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). /// /// A list of files attached to the message, and the tools they should be added to. /// 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. /// is an empty string, and was expected to be non-empty. - public virtual async Task> CreateMessageAsync(string threadId, MessageRole role, string content, IEnumerable attachments = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + public virtual async Task> CreateMessageAsync(string threadId, MessageRole role, BinaryData content, IEnumerable attachments = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNull(content, nameof(content)); @@ -1196,22 +1298,22 @@ public virtual async Task> CreateMessageAsync(string thr /// Identifier of the thread. /// /// The role of the entity that is creating the message. Allowed values include: - /// - `user`: Indicates the message is sent by an actual user and should be used in most - /// cases to represent user-generated messages. - /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert - /// messages from the agent into the - /// conversation. + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). /// /// - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via - /// a separate call to the create message API. + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). /// /// A list of files attached to the message, and the tools they should be added to. /// 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. /// is an empty string, and was expected to be non-empty. - public virtual Response CreateMessage(string threadId, MessageRole role, string content, IEnumerable attachments = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + public virtual Response CreateMessage(string threadId, MessageRole role, BinaryData content, IEnumerable attachments = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNull(content, nameof(content)); @@ -1232,7 +1334,7 @@ public virtual Response CreateMessage(string threadId, MessageRol /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// @@ -1273,7 +1375,7 @@ public virtual async Task CreateMessageAsync(string threadId, RequestC /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// @@ -5082,6 +5184,42 @@ internal HttpMessage CreateInternalDeleteThreadRequest(string threadId, RequestC return message; } + internal HttpMessage CreateGetThreadsRequest(int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/agents/v1.0/subscriptions/", false); + uri.AppendRaw(_subscriptionId, true); + uri.AppendRaw("/resourceGroups/", false); + uri.AppendRaw(_resourceGroupName, true); + uri.AppendRaw("/providers/Microsoft.MachineLearningServices/workspaces/", false); + uri.AppendRaw(_projectName, true); + uri.AppendPath("/threads", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + internal HttpMessage CreateCreateMessageRequest(string threadId, RequestContent content, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.Serialization.cs index ba6296e2fcd3..d7a013b6b267 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.Serialization.cs @@ -37,7 +37,14 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("role"u8); writer.WriteStringValue(Role.ToString()); writer.WritePropertyName("content"u8); - writer.WriteStringValue(Content); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif if (Optional.IsCollectionDefined(Attachments)) { if (Attachments != null) @@ -111,7 +118,7 @@ internal static CreateMessageRequest DeserializeCreateMessageRequest(JsonElement return null; } MessageRole role = default; - string content = default; + BinaryData content = default; IReadOnlyList attachments = default; IReadOnlyDictionary metadata = default; IDictionary serializedAdditionalRawData = default; @@ -125,7 +132,7 @@ internal static CreateMessageRequest DeserializeCreateMessageRequest(JsonElement } if (property.NameEquals("content"u8)) { - content = property.Value.GetString(); + content = BinaryData.FromString(property.Value.GetRawText()); continue; } if (property.NameEquals("attachments"u8)) diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.cs index 06f70fecdb8a..81df27722a94 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CreateMessageRequest.cs @@ -48,18 +48,18 @@ internal partial class CreateMessageRequest /// Initializes a new instance of . /// /// The role of the entity that is creating the message. Allowed values include: - /// - `user`: Indicates the message is sent by an actual user and should be used in most - /// cases to represent user-generated messages. - /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert - /// messages from the agent into the - /// conversation. + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). /// /// - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via - /// a separate call to the create message API. + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). /// /// is null. - internal CreateMessageRequest(MessageRole role, string content) + internal CreateMessageRequest(MessageRole role, BinaryData content) { Argument.AssertNotNull(content, nameof(content)); @@ -72,20 +72,20 @@ internal CreateMessageRequest(MessageRole role, string content) /// Initializes a new instance of . /// /// The role of the entity that is creating the message. Allowed values include: - /// - `user`: Indicates the message is sent by an actual user and should be used in most - /// cases to represent user-generated messages. - /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert - /// messages from the agent into the - /// conversation. + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). /// /// - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via - /// a separate call to the create message API. + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). /// /// A list of files attached to the message, and the tools they should be added to. /// 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 CreateMessageRequest(MessageRole role, string content, IReadOnlyList attachments, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + internal CreateMessageRequest(MessageRole role, BinaryData content, IReadOnlyList attachments, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) { Role = role; Content = content; @@ -101,18 +101,56 @@ internal CreateMessageRequest() /// /// The role of the entity that is creating the message. Allowed values include: - /// - `user`: Indicates the message is sent by an actual user and should be used in most - /// cases to represent user-generated messages. - /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert - /// messages from the agent into the - /// conversation. + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). /// public MessageRole Role { get; } /// - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via - /// a separate call to the create message API. + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// where T is of type + /// + /// + /// + /// 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 string Content { get; } + public BinaryData Content { get; } /// A list of files attached to the message, and the tools they should be added to. public IReadOnlyList Attachments { 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. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ImageDetailLevel.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ImageDetailLevel.cs new file mode 100644 index 000000000000..96fd8c43e7de --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ImageDetailLevel.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Specifies an image's detail level. Can be 'auto', 'low', 'high', or an unknown future value. + public readonly partial struct ImageDetailLevel : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ImageDetailLevel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutoValue = "auto"; + private const string LowValue = "low"; + private const string HighValue = "high"; + + /// Automatically select an appropriate detail level. + public static ImageDetailLevel Auto { get; } = new ImageDetailLevel(AutoValue); + /// Use a lower detail level to reduce bandwidth or cost. + public static ImageDetailLevel Low { get; } = new ImageDetailLevel(LowValue); + /// Use a higher detail level—potentially more resource-intensive. + public static ImageDetailLevel High { get; } = new ImageDetailLevel(HighValue); + /// Determines if two values are the same. + public static bool operator ==(ImageDetailLevel left, ImageDetailLevel right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ImageDetailLevel left, ImageDetailLevel right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ImageDetailLevel(string value) => new ImageDetailLevel(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageDetailLevel other && Equals(other); + /// + public bool Equals(ImageDetailLevel 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/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.cs index 024f0dd9bb72..92712dbc0601 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.cs @@ -14,7 +14,7 @@ namespace Azure.AI.Projects public partial class MAASModelConfig : TargetModelConfig { /// Initializes a new instance of . - /// Endpoint URL for MAAS model. + /// Endpoint targetURI for MAAS model. /// API Key for MAAS model. /// or is null. public MAASModelConfig(string azureEndpoint, string apiKey) @@ -30,7 +30,7 @@ public MAASModelConfig(string azureEndpoint, string apiKey) /// Initializes a new instance of . /// Type of the model configuration. /// Keeps track of any properties unknown to the library. - /// Endpoint URL for MAAS model. + /// Endpoint targetURI for MAAS model. /// API Key for MAAS model. internal MAASModelConfig(string type, IDictionary serializedAdditionalRawData, string azureEndpoint, string apiKey) : base(type, serializedAdditionalRawData) { @@ -43,7 +43,7 @@ internal MAASModelConfig() { } - /// Endpoint URL for MAAS model. + /// Endpoint targetURI for MAAS model. public string AzureEndpoint { get; set; } /// API Key for MAAS model. public string ApiKey { get; set; } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageBlockType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageBlockType.cs new file mode 100644 index 000000000000..c39ca285de4d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageBlockType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Specifies the kind of content block within a message. Could be text, an image file, an external image URL, or an unknown future type. + internal readonly partial struct MessageBlockType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageBlockType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TextValue = "text"; + private const string ImageFileValue = "image_file"; + private const string ImageUrlValue = "image_url"; + + /// Indicates a block containing text content. + public static MessageBlockType Text { get; } = new MessageBlockType(TextValue); + /// Indicates a block referencing an internally uploaded image file. + public static MessageBlockType ImageFile { get; } = new MessageBlockType(ImageFileValue); + /// Indicates a block referencing an external image URL. + public static MessageBlockType ImageUrl { get; } = new MessageBlockType(ImageUrlValue); + /// Determines if two values are the same. + public static bool operator ==(MessageBlockType left, MessageBlockType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageBlockType left, MessageBlockType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MessageBlockType(string value) => new MessageBlockType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageBlockType other && Equals(other); + /// + public bool Equals(MessageBlockType 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/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.Serialization.cs new file mode 100644 index 000000000000..887adde7db9c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.Serialization.cs @@ -0,0 +1,157 @@ +// 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.Projects +{ + public partial class MessageImageFileParam : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageImageFileParam)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + if (Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageImageFileParam 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(MessageImageFileParam)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageImageFileParam(document.RootElement, options); + } + + internal static MessageImageFileParam DeserializeMessageImageFileParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + ImageDetailLevel? detail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("detail"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + detail = new ImageDetailLevel(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageImageFileParam(fileId, detail, 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(MessageImageFileParam)} does not support writing '{options.Format}' format."); + } + } + + MessageImageFileParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageImageFileParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageImageFileParam)} 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 MessageImageFileParam FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageImageFileParam(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/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.cs new file mode 100644 index 000000000000..7d8ac41222aa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageFileParam.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Defines how an internally uploaded image file is referenced when creating an image-file block. + public partial class MessageImageFileParam + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the previously uploaded image file. + /// is null. + public MessageImageFileParam(string fileId) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + } + + /// Initializes a new instance of . + /// The ID of the previously uploaded image file. + /// Optional detail level for the image (auto, low, or high). + /// Keeps track of any properties unknown to the library. + internal MessageImageFileParam(string fileId, ImageDetailLevel? detail, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Detail = detail; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageImageFileParam() + { + } + + /// The ID of the previously uploaded image file. + public string FileId { get; } + /// Optional detail level for the image (auto, low, or high). + public ImageDetailLevel? Detail { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.Serialization.cs new file mode 100644 index 000000000000..315d9d39625f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.Serialization.cs @@ -0,0 +1,157 @@ +// 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.Projects +{ + public partial class MessageImageUrlParam : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageImageUrlParam)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url); + if (Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageImageUrlParam 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(MessageImageUrlParam)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageImageUrlParam(document.RootElement, options); + } + + internal static MessageImageUrlParam DeserializeMessageImageUrlParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string url = default; + ImageDetailLevel? detail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url"u8)) + { + url = property.Value.GetString(); + continue; + } + if (property.NameEquals("detail"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + detail = new ImageDetailLevel(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageImageUrlParam(url, detail, 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(MessageImageUrlParam)} does not support writing '{options.Format}' format."); + } + } + + MessageImageUrlParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageImageUrlParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageImageUrlParam)} 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 MessageImageUrlParam FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageImageUrlParam(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/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.cs new file mode 100644 index 000000000000..5bdb1cda03f9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageImageUrlParam.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Defines how an external image URL is referenced when creating an image-URL block. + public partial class MessageImageUrlParam + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The publicly accessible URL of the external image. + /// is null. + public MessageImageUrlParam(string url) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + /// Initializes a new instance of . + /// The publicly accessible URL of the external image. + /// Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. + /// Keeps track of any properties unknown to the library. + internal MessageImageUrlParam(string url, ImageDetailLevel? detail, IDictionary serializedAdditionalRawData) + { + Url = url; + Detail = detail; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageImageUrlParam() + { + } + + /// The publicly accessible URL of the external image. + public string Url { get; } + /// Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. + public ImageDetailLevel? Detail { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.Serialization.cs new file mode 100644 index 000000000000..486d218d8a5f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.Serialization.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects +{ + [PersistableModelProxy(typeof(UnknownMessageInputContentBlock))] + public partial class MessageInputContentBlock : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageInputContentBlock 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(MessageInputContentBlock)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageInputContentBlock(document.RootElement, options); + } + + internal static MessageInputContentBlock DeserializeMessageInputContentBlock(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "image_file": return MessageInputImageFileBlock.DeserializeMessageInputImageFileBlock(element, options); + case "image_url": return MessageInputImageUrlBlock.DeserializeMessageInputImageUrlBlock(element, options); + case "text": return MessageInputTextBlock.DeserializeMessageInputTextBlock(element, options); + } + } + return UnknownMessageInputContentBlock.DeserializeUnknownMessageInputContentBlock(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support writing '{options.Format}' format."); + } + } + + MessageInputContentBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputContentBlock(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageInputContentBlock)} 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 MessageInputContentBlock FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputContentBlock(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/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.cs new file mode 100644 index 000000000000..833cdad0dbcf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputContentBlock.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// Defines a single content block when creating a message. The 'type' field determines whether it is text, an image file, or an external image URL, etc. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class MessageInputContentBlock + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected MessageInputContentBlock() + { + } + + /// Initializes a new instance of . + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + /// Keeps track of any properties unknown to the library. + internal MessageInputContentBlock(MessageBlockType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + internal MessageBlockType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.Serialization.cs new file mode 100644 index 000000000000..59482feb23ce --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.Serialization.cs @@ -0,0 +1,134 @@ +// 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.Projects +{ + public partial class MessageInputImageFileBlock : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputImageFileBlock)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("image_file"u8); + writer.WriteObjectValue(ImageFile, options); + } + + MessageInputImageFileBlock 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(MessageInputImageFileBlock)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageInputImageFileBlock(document.RootElement, options); + } + + internal static MessageInputImageFileBlock DeserializeMessageInputImageFileBlock(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageImageFileParam imageFile = default; + MessageBlockType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image_file"u8)) + { + imageFile = MessageImageFileParam.DeserializeMessageImageFileParam(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new MessageBlockType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageInputImageFileBlock(type, serializedAdditionalRawData, imageFile); + } + + 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(MessageInputImageFileBlock)} does not support writing '{options.Format}' format."); + } + } + + MessageInputImageFileBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputImageFileBlock(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageInputImageFileBlock)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageInputImageFileBlock FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputImageFileBlock(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.cs new file mode 100644 index 000000000000..fe86d8a41677 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageFileBlock.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// An image-file block in a new message, referencing an internally uploaded image by file ID. + public partial class MessageInputImageFileBlock : MessageInputContentBlock + { + /// Initializes a new instance of . + /// Information about the referenced image file, including file ID and optional detail level. + /// is null. + public MessageInputImageFileBlock(MessageImageFileParam imageFile) + { + Argument.AssertNotNull(imageFile, nameof(imageFile)); + + Type = MessageBlockType.ImageFile; + ImageFile = imageFile; + } + + /// Initializes a new instance of . + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + /// Keeps track of any properties unknown to the library. + /// Information about the referenced image file, including file ID and optional detail level. + internal MessageInputImageFileBlock(MessageBlockType type, IDictionary serializedAdditionalRawData, MessageImageFileParam imageFile) : base(type, serializedAdditionalRawData) + { + ImageFile = imageFile; + } + + /// Initializes a new instance of for deserialization. + internal MessageInputImageFileBlock() + { + } + + /// Information about the referenced image file, including file ID and optional detail level. + public MessageImageFileParam ImageFile { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.Serialization.cs new file mode 100644 index 000000000000..3551fdc2f53e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.Serialization.cs @@ -0,0 +1,134 @@ +// 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.Projects +{ + public partial class MessageInputImageUrlBlock : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputImageUrlBlock)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("image_url"u8); + writer.WriteObjectValue(ImageUrl, options); + } + + MessageInputImageUrlBlock 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(MessageInputImageUrlBlock)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageInputImageUrlBlock(document.RootElement, options); + } + + internal static MessageInputImageUrlBlock DeserializeMessageInputImageUrlBlock(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageImageUrlParam imageUrl = default; + MessageBlockType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image_url"u8)) + { + imageUrl = MessageImageUrlParam.DeserializeMessageImageUrlParam(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new MessageBlockType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageInputImageUrlBlock(type, serializedAdditionalRawData, imageUrl); + } + + 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(MessageInputImageUrlBlock)} does not support writing '{options.Format}' format."); + } + } + + MessageInputImageUrlBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputImageUrlBlock(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageInputImageUrlBlock)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageInputImageUrlBlock FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputImageUrlBlock(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.cs new file mode 100644 index 000000000000..7bcaf487cecc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputImageUrlBlock.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// An image-URL block in a new message, referencing an external image by URL. + public partial class MessageInputImageUrlBlock : MessageInputContentBlock + { + /// Initializes a new instance of . + /// Information about the external image URL, including the URL and optional detail level. + /// is null. + public MessageInputImageUrlBlock(MessageImageUrlParam imageUrl) + { + Argument.AssertNotNull(imageUrl, nameof(imageUrl)); + + Type = MessageBlockType.ImageUrl; + ImageUrl = imageUrl; + } + + /// Initializes a new instance of . + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + /// Keeps track of any properties unknown to the library. + /// Information about the external image URL, including the URL and optional detail level. + internal MessageInputImageUrlBlock(MessageBlockType type, IDictionary serializedAdditionalRawData, MessageImageUrlParam imageUrl) : base(type, serializedAdditionalRawData) + { + ImageUrl = imageUrl; + } + + /// Initializes a new instance of for deserialization. + internal MessageInputImageUrlBlock() + { + } + + /// Information about the external image URL, including the URL and optional detail level. + public MessageImageUrlParam ImageUrl { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.Serialization.cs new file mode 100644 index 000000000000..1e8efcb6934e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.Serialization.cs @@ -0,0 +1,134 @@ +// 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.Projects +{ + public partial class MessageInputTextBlock : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputTextBlock)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + + MessageInputTextBlock 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(MessageInputTextBlock)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageInputTextBlock(document.RootElement, options); + } + + internal static MessageInputTextBlock DeserializeMessageInputTextBlock(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + MessageBlockType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new MessageBlockType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageInputTextBlock(type, serializedAdditionalRawData, text); + } + + 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(MessageInputTextBlock)} does not support writing '{options.Format}' format."); + } + } + + MessageInputTextBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputTextBlock(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageInputTextBlock)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageInputTextBlock FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputTextBlock(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.cs new file mode 100644 index 000000000000..1e7846da5eb5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MessageInputTextBlock.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A text block in a new message, containing plain text content. + public partial class MessageInputTextBlock : MessageInputContentBlock + { + /// Initializes a new instance of . + /// The plain text content for this block. + /// is null. + public MessageInputTextBlock(string text) + { + Argument.AssertNotNull(text, nameof(text)); + + Type = MessageBlockType.Text; + Text = text; + } + + /// Initializes a new instance of . + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + /// Keeps track of any properties unknown to the library. + /// The plain text content for this block. + internal MessageInputTextBlock(MessageBlockType type, IDictionary serializedAdditionalRawData, string text) : base(type, serializedAdditionalRawData) + { + Text = text; + } + + /// Initializes a new instance of for deserialization. + internal MessageInputTextBlock() + { + } + + /// The plain text content for this block. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.Serialization.cs new file mode 100644 index 000000000000..7fb70193f404 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.Serialization.cs @@ -0,0 +1,190 @@ +// 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.Projects +{ + public partial class OpenAIPageableListOfAgentThread : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfAgentThread)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenAIPageableListOfAgentThread 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(OpenAIPageableListOfAgentThread)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfAgentThread(document.RootElement, options); + } + + internal static OpenAIPageableListOfAgentThread DeserializeOpenAIPageableListOfAgentThread(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfAgentThreadObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfAgentThreadObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AgentThread.DeserializeAgentThread(item, options)); + } + data = array; + continue; + } + if (property.NameEquals("first_id"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIPageableListOfAgentThread( + @object, + data, + firstId, + lastId, + hasMore, + 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(OpenAIPageableListOfAgentThread)} does not support writing '{options.Format}' format."); + } + } + + OpenAIPageableListOfAgentThread IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfAgentThread(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfAgentThread)} 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 OpenAIPageableListOfAgentThread FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfAgentThread(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/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.cs new file mode 100644 index 000000000000..52088bd71a97 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThread.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// The response data for a requested list of items. + public partial class OpenAIPageableListOfAgentThread + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// , or is null. + internal OpenAIPageableListOfAgentThread(IEnumerable data, string firstId, string lastId, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// Keeps track of any properties unknown to the library. + internal OpenAIPageableListOfAgentThread(OpenAIPageableListOfAgentThreadObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenAIPageableListOfAgentThread() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfAgentThreadObject Object { get; } = OpenAIPageableListOfAgentThreadObject.List; + + /// The requested list of items. + public IReadOnlyList Data { get; } + /// The first ID represented in this list. + public string FirstId { get; } + /// The last ID represented in this list. + public string LastId { get; } + /// A value indicating whether there are additional values available not captured in this list. + public bool HasMore { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThreadObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThreadObject.cs new file mode 100644 index 000000000000..ff5c68a5d4e9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenAIPageableListOfAgentThreadObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The OpenAIPageableListOfAgentThread_object. + public readonly partial struct OpenAIPageableListOfAgentThreadObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfAgentThreadObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfAgentThreadObject List { get; } = new OpenAIPageableListOfAgentThreadObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfAgentThreadObject left, OpenAIPageableListOfAgentThreadObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfAgentThreadObject left, OpenAIPageableListOfAgentThreadObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenAIPageableListOfAgentThreadObject(string value) => new OpenAIPageableListOfAgentThreadObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfAgentThreadObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfAgentThreadObject 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/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.Serialization.cs index cc8f8fb239ee..2877cf89ea01 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.Serialization.cs @@ -37,7 +37,14 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("role"u8); writer.WriteStringValue(Role.ToString()); writer.WritePropertyName("content"u8); - writer.WriteStringValue(Content); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif if (Optional.IsCollectionDefined(Attachments)) { if (Attachments != null) @@ -111,7 +118,7 @@ internal static ThreadMessageOptions DeserializeThreadMessageOptions(JsonElement return null; } MessageRole role = default; - string content = default; + BinaryData content = default; IList attachments = default; IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; @@ -125,7 +132,7 @@ internal static ThreadMessageOptions DeserializeThreadMessageOptions(JsonElement } if (property.NameEquals("content"u8)) { - content = property.Value.GetString(); + content = BinaryData.FromString(property.Value.GetRawText()); continue; } if (property.NameEquals("attachments"u8)) diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.cs index dbff5c77a2dc..4a6ca018b978 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadMessageOptions.cs @@ -10,7 +10,10 @@ namespace Azure.AI.Projects { - /// A single message within an agent thread, as provided during that thread's creation for its initial state. + /// + /// A single message within an agent thread, + /// as provided during that thread's creation for its initial state. + /// public partial class ThreadMessageOptions { /// @@ -48,18 +51,18 @@ public partial class ThreadMessageOptions /// Initializes a new instance of . /// /// The role of the entity that is creating the message. Allowed values include: - /// - `user`: Indicates the message is sent by an actual user and should be used in most - /// cases to represent user-generated messages. - /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert - /// messages from the agent into the - /// conversation. + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). /// /// - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via - /// a separate call to the create message API. + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). /// /// is null. - public ThreadMessageOptions(MessageRole role, string content) + public ThreadMessageOptions(MessageRole role, BinaryData content) { Argument.AssertNotNull(content, nameof(content)); @@ -72,20 +75,20 @@ public ThreadMessageOptions(MessageRole role, string content) /// Initializes a new instance of . /// /// The role of the entity that is creating the message. Allowed values include: - /// - `user`: Indicates the message is sent by an actual user and should be used in most - /// cases to represent user-generated messages. - /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert - /// messages from the agent into the - /// conversation. + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). /// /// - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via - /// a separate call to the create message API. + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). /// /// A list of files attached to the message, and the tools they should be added to. /// 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 ThreadMessageOptions(MessageRole role, string content, IList attachments, IDictionary metadata, IDictionary serializedAdditionalRawData) + internal ThreadMessageOptions(MessageRole role, BinaryData content, IList attachments, IDictionary metadata, IDictionary serializedAdditionalRawData) { Role = role; Content = content; @@ -101,18 +104,56 @@ internal ThreadMessageOptions() /// /// The role of the entity that is creating the message. Allowed values include: - /// - `user`: Indicates the message is sent by an actual user and should be used in most - /// cases to represent user-generated messages. - /// - `assistant`: Indicates the message is generated by the agent. Use this value to insert - /// messages from the agent into the - /// conversation. + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). /// public MessageRole Role { get; } /// - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via - /// a separate call to the create message API. + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// where T is of type + /// + /// + /// + /// 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 string Content { get; } + public BinaryData Content { get; } /// A list of files attached to the message, and the tools they should be added to. public IList Attachments { 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. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.Serialization.cs new file mode 100644 index 000000000000..c92fbcb01b32 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.Serialization.cs @@ -0,0 +1,126 @@ +// 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.Projects +{ + internal partial class UnknownMessageInputContentBlock : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + MessageInputContentBlock 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(MessageInputContentBlock)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageInputContentBlock(document.RootElement, options); + } + + internal static UnknownMessageInputContentBlock DeserializeUnknownMessageInputContentBlock(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageBlockType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new MessageBlockType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageInputContentBlock(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(MessageInputContentBlock)} does not support writing '{options.Format}' format."); + } + } + + MessageInputContentBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputContentBlock(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownMessageInputContentBlock FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownMessageInputContentBlock(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.cs new file mode 100644 index 000000000000..3ad239e8a6e0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMessageInputContentBlock.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Unknown version of MessageInputContentBlock. + internal partial class UnknownMessageInputContentBlock : MessageInputContentBlock + { + /// Initializes a new instance of . + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + /// Keeps track of any properties unknown to the library. + internal UnknownMessageInputContentBlock(MessageBlockType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownMessageInputContentBlock() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/tsp-location.yaml b/sdk/ai/Azure.AI.Projects/tsp-location.yaml index a6ba77da2429..87ef6554f94f 100644 --- a/sdk/ai/Azure.AI.Projects/tsp-location.yaml +++ b/sdk/ai/Azure.AI.Projects/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/ai/Azure.AI.Projects -commit: 32ce49f1d6d078aca05b3f88883dfd480d5af399 +commit: 83c7eaf56263c3f323275b9195829cad55b43a77 repo: Azure/azure-rest-api-specs additionalDirectories: