Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -2,7 +2,6 @@

using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Azure.AI.Projects;
using Azure.Identity;
Expand All @@ -21,12 +20,13 @@
{
private const string WorkflowWithConversationFileName = "MediaInputConversation.yaml";
private const string WorkflowWithAutoSendFileName = "MediaInputAutoSend.yaml";
private const string ImageReference = "https://sample-files.com/downloads/images/jpg/web_optimized_1200x800_97kb.jpg";
private const string PdfReference = "https://sample-files.com/downloads/documents/pdf/basic-text.pdf";
private const string ImageReferenceUrl = "https://sample-files.com/downloads/images/jpg/web_optimized_1200x800_97kb.jpg";
private const string PdfLocalFile = "TestFiles/basic-text.pdf";
private const string ImageLocalFile = "TestFiles/test-image.jpg";

[Theory]
[InlineData(ImageReference, "image/jpeg", true)]
[InlineData(ImageReference, "image/jpeg", false)]
[InlineData(ImageReferenceUrl, "image/jpeg", true)]
[InlineData(ImageReferenceUrl, "image/jpeg", false)]
public async Task ValidateFileUrlAsync(string fileSource, string mediaType, bool useConversation)
{
// Arrange
Expand All @@ -39,12 +39,12 @@
// Temporarily disabled
[Theory]
[Trait("Category", "IntegrationDisabled")]
[InlineData(ImageReference, "image/jpeg", true)]
[InlineData(ImageReference, "image/jpeg", false)]
[InlineData(ImageLocalFile, "image/jpeg", true)]
[InlineData(ImageLocalFile, "image/jpeg", false)]
public async Task ValidateImageFileDataAsync(string fileSource, string mediaType, bool useConversation)
{
// Arrange
byte[] fileData = await DownloadFileAsync(fileSource);
byte[] fileData = await File.ReadAllBytesAsync(fileSource);

Check failure on line 47 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net9.0, windows-latest, Debug)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 47 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net9.0, windows-latest, Debug)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 47 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net8.0, ubuntu-latest, Release)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 47 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net8.0, ubuntu-latest, Release)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 47 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net472, windows-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 47 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net472, windows-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 47 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net10.0, ubuntu-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 47 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net10.0, ubuntu-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'
string encodedData = Convert.ToBase64String(fileData);
string fileUrl = $"data:{mediaType};base64,{encodedData}";
this.Output.WriteLine($"Content: {fileUrl.Substring(0, Math.Min(112, fileUrl.Length))}...");
Expand All @@ -54,12 +54,12 @@
}

[Theory]
[InlineData(PdfReference, "application/pdf", true)]
[InlineData(PdfReference, "application/pdf", false)]
[InlineData(PdfLocalFile, "application/pdf", true)]
[InlineData(PdfLocalFile, "application/pdf", false)]
public async Task ValidateFileDataAsync(string fileSource, string mediaType, bool useConversation)
{
// Arrange
byte[] fileData = await DownloadFileAsync(fileSource);
byte[] fileData = await File.ReadAllBytesAsync(fileSource);

Check failure on line 62 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net9.0, windows-latest, Debug)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 62 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net9.0, windows-latest, Debug)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 62 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net8.0, ubuntu-latest, Release)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 62 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net8.0, ubuntu-latest, Release)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 62 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net472, windows-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 62 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net472, windows-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 62 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net10.0, ubuntu-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 62 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net10.0, ubuntu-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'
string encodedData = Convert.ToBase64String(fileData);
string fileUrl = $"data:{mediaType};base64,{encodedData}";
this.Output.WriteLine($"Content: {fileUrl.Substring(0, Math.Min(112, fileUrl.Length))}...");
Expand All @@ -71,12 +71,12 @@
// Temporarily disabled
[Theory]
[Trait("Category", "IntegrationDisabled")]
[InlineData(PdfReference, "doc.pdf", true)]
[InlineData(PdfReference, "doc.pdf", false)]
[InlineData(PdfLocalFile, "doc.pdf", true)]
[InlineData(PdfLocalFile, "doc.pdf", false)]
public async Task ValidateFileUploadAsync(string fileSource, string documentName, bool useConversation)
{
// Arrange
byte[] fileData = await DownloadFileAsync(fileSource);
byte[] fileData = await File.ReadAllBytesAsync(fileSource);

Check failure on line 79 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net9.0, windows-latest, Debug)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 79 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net9.0, windows-latest, Debug)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 79 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net8.0, ubuntu-latest, Release)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 79 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net8.0, ubuntu-latest, Release)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 79 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net472, windows-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 79 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net472, windows-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 79 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net10.0, ubuntu-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'

Check failure on line 79 in dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/MediaInputTest.cs

View workflow job for this annotation

GitHub Actions / dotnet-build-and-test (net10.0, ubuntu-latest, Release, true, integration)

'File' does not contain a definition for 'ReadAllBytesAsync'
AIProjectClient client = new(this.TestEndpoint, new AzureCliCredential());
using MemoryStream contentStream = new(fileData);
OpenAIFileClient fileClient = client.GetProjectOpenAIClient().GetOpenAIFileClient();
Expand All @@ -94,13 +94,6 @@
}
}

private static async Task<byte[]> DownloadFileAsync(string uri)
{
using HttpClient client = new();
client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0");
return await client.GetByteArrayAsync(new Uri(uri));
}

private async Task ValidateFileAsync(AIContent fileContent, bool useConversation)
{
// Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<None Update="Workflows\*.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestFiles\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading