Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,10 @@ public string? MediaType
public string? Name { get; set; }

/// <summary>Gets or sets the size of the file in bytes.</summary>
[Experimental(DiagnosticIds.Experiments.AIFiles, UrlFormat = DiagnosticIds.UrlFormat)]
[JsonIgnore]
public long? SizeInBytes
{
get => SizeInBytesCore;
set => SizeInBytesCore = value;
}

[JsonInclude]
[JsonPropertyName("sizeInBytes")]
internal long? SizeInBytesCore { get; set; }
public long? SizeInBytes { get; set; }

/// <summary>Gets or sets when the file was created.</summary>
[Experimental(DiagnosticIds.Experiments.AIFiles, UrlFormat = DiagnosticIds.UrlFormat)]
[JsonIgnore]
public DateTimeOffset? CreatedAt
{
get => CreatedAtCore;
set => CreatedAtCore = value;
}

[JsonInclude]
[JsonPropertyName("createdAt")]
internal DateTimeOffset? CreatedAtCore { get; set; }
public DateTimeOffset? CreatedAt { get; set; }

/// <summary>Gets or sets the purpose for which the file was uploaded.</summary>
/// <remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,7 @@
"Properties": [
{
"Member": "System.DateTimeOffset? Microsoft.Extensions.AI.HostedFileContent.CreatedAt { get; set; }",
"Stage": "Experimental"
"Stage": "Stable"
},
{
"Member": "string Microsoft.Extensions.AI.HostedFileContent.FileId { get; set; }",
Expand All @@ -2423,7 +2423,7 @@
},
{
"Member": "long? Microsoft.Extensions.AI.HostedFileContent.SizeInBytes { get; set; }",
"Stage": "Experimental"
"Stage": "Stable"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#pragma warning disable MEAI001

using System;
using System.Text.Json;
using Xunit;
Expand All @@ -28,8 +26,10 @@ public void Constructor_String_PropsDefault()
Assert.Null(c.AdditionalProperties);
Assert.Null(c.SizeInBytes);
Assert.Null(c.CreatedAt);
#pragma warning disable MEAI001
Assert.Null(c.Purpose);
Assert.Null(c.Scope);
#pragma warning restore MEAI001
Assert.Equal(fileId, c.FileId);
}

Expand Down Expand Up @@ -153,6 +153,7 @@ public void CreatedAt_Roundtrips()
Assert.Null(c.CreatedAt);
}

#pragma warning disable MEAI001
[Fact]
public void Purpose_Roundtrips()
{
Expand All @@ -178,6 +179,7 @@ public void Scope_Roundtrips()
c.Scope = null;
Assert.Null(c.Scope);
}
#pragma warning restore MEAI001

[Fact]
public void Serialization_IncludesExperimentalProperties()
Expand All @@ -189,8 +191,10 @@ public void Serialization_IncludesExperimentalProperties()
MediaType = "text/plain",
SizeInBytes = 1024,
CreatedAt = now,
#pragma warning disable MEAI001
Purpose = "fine-tune",
Scope = "container-1",
#pragma warning restore MEAI001
};

var json = JsonSerializer.Serialize(content, AIJsonUtilities.DefaultOptions);
Expand All @@ -204,8 +208,10 @@ public void Serialization_IncludesExperimentalProperties()
Assert.NotNull(deserialized);
Assert.Equal(1024, deserialized.SizeInBytes);
Assert.Equal(now, deserialized.CreatedAt);
#pragma warning disable MEAI001
Assert.Equal("fine-tune", deserialized.Purpose);
Assert.Equal("container-1", deserialized.Scope);
#pragma warning restore MEAI001
}

[Theory]
Expand Down Expand Up @@ -257,8 +263,10 @@ public void JsonDeserialization_KnownPayload()
Assert.Equal("document.pdf", hostedFile.Name);
Assert.Equal(1024, hostedFile.SizeInBytes);
Assert.Equal(new DateTimeOffset(2024, 1, 15, 10, 30, 0, TimeSpan.Zero), hostedFile.CreatedAt);
#pragma warning disable MEAI001
Assert.Equal("assistants", hostedFile.Purpose);
Assert.Equal("user", hostedFile.Scope);
#pragma warning restore MEAI001
Assert.NotNull(hostedFile.AdditionalProperties);
Assert.Equal("val", hostedFile.AdditionalProperties["key"]?.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public void Properties_Roundtrip()
{
ImageGenerationOptions options = new();

#pragma warning disable MEAI001 // IImageGenerator is experimental
Func<IImageGenerator, object?> factory = generator => new { Representation = "raw data" };
#pragma warning restore MEAI001

options.ResponseFormat = ImageGenerationResponseFormat.Data;
options.Count = 5;
Expand Down Expand Up @@ -72,9 +74,9 @@ public void JsonSerialization_Roundtrips()
ModelId = "test-model",
};

string json = JsonSerializer.Serialize(options, TestJsonSerializerContext.Default.ImageGenerationOptions);
string json = JsonSerializer.Serialize(options, AIJsonUtilities.DefaultOptions);

ImageGenerationOptions? deserialized = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ImageGenerationOptions);
ImageGenerationOptions? deserialized = JsonSerializer.Deserialize<ImageGenerationOptions>(json, AIJsonUtilities.DefaultOptions);
Assert.NotNull(deserialized);

Assert.Equal(ImageGenerationResponseFormat.Data, deserialized.ResponseFormat);
Expand Down Expand Up @@ -116,7 +118,9 @@ public void Clone_CreatesIndependentCopy()
[Theory]
[InlineData(ImageGenerationResponseFormat.Uri)]
[InlineData(ImageGenerationResponseFormat.Data)]
#pragma warning disable MEAI001 // ImageGenerationResponseFormat.Hosted is experimental
[InlineData(ImageGenerationResponseFormat.Hosted)]
#pragma warning restore MEAI001
public void ImageGenerationResponseFormat_Values_AreValid(ImageGenerationResponseFormat responseFormat)
{
Assert.True(Enum.IsDefined(typeof(ImageGenerationResponseFormat), responseFormat));
Expand All @@ -127,8 +131,8 @@ public void ImageGenerationResponseFormat_JsonSerialization_Roundtrips()
{
foreach (ImageGenerationResponseFormat responseFormat in Enum.GetValues(typeof(ImageGenerationResponseFormat)))
{
string json = JsonSerializer.Serialize(responseFormat, TestJsonSerializerContext.Default.ImageGenerationResponseFormat);
ImageGenerationResponseFormat deserialized = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ImageGenerationResponseFormat);
string json = JsonSerializer.Serialize(responseFormat, AIJsonUtilities.DefaultOptions);
ImageGenerationResponseFormat deserialized = JsonSerializer.Deserialize<ImageGenerationResponseFormat>(json, AIJsonUtilities.DefaultOptions);
Assert.Equal(responseFormat, deserialized);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Microsoft.Extensions.AI</RootNamespace>
<Description>Stabilization tests for ImageGeneration, CodeInterpreter, and WebSearch content types (no MEAI001 suppression).</Description>
<Description>Stabilization tests (no MEAI001 suppression).</Description>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -22,13 +22,15 @@
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\ResponseContinuationTokenTests.cs" Link="ResponseContinuationTokenTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolCallContentTests.cs" Link="Contents\CodeInterpreterToolCallContentTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolResultContentTests.cs" Link="Contents\CodeInterpreterToolResultContentTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Contents\HostedFileContentTests.cs" Link="Contents\HostedFileContentTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Contents\ImageGenerationToolCallContentTests.cs" Link="Contents\ImageGenerationToolCallContentTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Contents\ImageGenerationToolResultContentTests.cs" Link="Contents\ImageGenerationToolResultContentTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Contents\WebSearchToolCallContentTests.cs" Link="Contents\WebSearchToolCallContentTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Contents\WebSearchToolResultContentTests.cs" Link="Contents\WebSearchToolResultContentTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Tools\HostedCodeInterpreterToolTests.cs" Link="Tools\HostedCodeInterpreterToolTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Tools\HostedImageGenerationToolTests.cs" Link="Tools\HostedImageGenerationToolTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Tools\HostedWebSearchToolTests.cs" Link="Tools\HostedWebSearchToolTests.cs" />
<Compile Include="..\Microsoft.Extensions.AI.Abstractions.Tests\Image\ImageGenerationOptionsTests.cs" Link="Image\ImageGenerationOptionsTests.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading