86 instantiations of HostedFileContent
Microsoft.Extensions.AI.Abstractions.Tests (34)
Contents\AIContentTests.cs (1)
74new HostedFileContent("file123"),
Contents\CodeInterpreterToolCallContentTests.cs (2)
53new HostedFileContent("file123"), 73new HostedFileContent("file456")
Contents\CodeInterpreterToolResultContentTests.cs (2)
53new HostedFileContent("output.png"), 75new HostedFileContent("result.txt")
Contents\HostedFileContentTests.cs (17)
15Assert.Throws<ArgumentNullException>("fileId", () => new HostedFileContent(null!)); 16Assert.Throws<ArgumentException>("fileId", () => new HostedFileContent(string.Empty)); 17Assert.Throws<ArgumentException>("fileId", () => new HostedFileContent(" ")); 24HostedFileContent c = new(fileId); 39HostedFileContent c = new("id123"); 63var content = new HostedFileContent("file123"); 75HostedFileContent c = new("id123"); 97HostedFileContent c = new("id123"); 109HostedFileContent c = new("id123") { MediaType = mediaType }; 116HostedFileContent c = new("id123"); 132HostedFileContent c = new("id123"); 145HostedFileContent c = new("id123"); 160HostedFileContent c = new("id123"); 173HostedFileContent c = new("id123"); 188var content = new HostedFileContent("file123") 226HostedFileContent c = new("id123") { MediaType = mediaType }; 233HostedFileContent c = new("id123");
Files\DelegatingHostedFileClientTests.cs (4)
32var expectedFile = new HostedFileContent("file-123"); 88var expectedFile = new HostedFileContent("file-789") { Name = "info.txt" }; 115new HostedFileContent("file-1"), 116new HostedFileContent("file-2")
Files\HostedFileClientExtensionsTests.cs (6)
31return Task.FromResult(new HostedFileContent("file-1")); 82return new HostedFileContent("file-2"); 289var hostedFileContent = new HostedFileContent("file-hfc"); 308var content = new HostedFileContent("file-1"); 322var hostedFileContent = new HostedFileContent("file-scoped") { Scope = "container-42" }; 341var hostedFileContent = new HostedFileContent("file-scoped") { Scope = "container-from-content" };
Tools\HostedCodeInterpreterToolTests.cs (1)
47new HostedFileContent("id123"),
Tools\HostedFileSearchToolTests.cs (1)
49new HostedFileContent("id456"),
Microsoft.Extensions.AI.OpenAI (6)
OpenAIChatClient.cs (1)
811contentPart.FileId is not null ? new HostedFileContent(contentPart.FileId) { Name = contentPart.Filename } :
OpenAIHostedFileClient.cs (2)
328new(openAIFile.Id) 347return new HostedFileContent(file.Id)
OpenAIResponsesChatClient.cs (3)
1701content = new HostedFileContent(part.InputImageFileId) { MediaType = "image/*" }; 1705content = new HostedFileContent(part.InputFileId) { Name = part.InputFilename }; 1957var hfc = new HostedFileContent(fileId) { MediaType = mimeType, RawRepresentation = output };
Microsoft.Extensions.AI.OpenAI.Tests (6)
OpenAIConversionTests.cs (1)
351var fileContent = new HostedFileContent("file-123");
OpenAIResponseClientTests.cs (5)
5056new FunctionResultContent("call_file", new HostedFileContent("file-abc123") { MediaType = "image/png", Name = "result.png" }) 5402new FunctionResultContent("call_hosted_file", new HostedFileContent("file-xyz789") { MediaType = "text/plain", Name = "document.txt" }) 5576new HostedFileContent("file-img-456") { MediaType = "image/png" }, 5577new HostedFileContent("file-img-789") { MediaType = "image/jpeg", AdditionalProperties = new AdditionalPropertiesDictionary { ["detail"] = "high" }}, 5578new HostedFileContent("file-123"),
Microsoft.Extensions.AI.Stabilization.Tests (22)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolCallContentTests.cs (2)
53new HostedFileContent("file123"), 73new HostedFileContent("file456")
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolResultContentTests.cs (2)
53new HostedFileContent("output.png"), 75new HostedFileContent("result.txt")
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\HostedFileContentTests.cs (17)
15Assert.Throws<ArgumentNullException>("fileId", () => new HostedFileContent(null!)); 16Assert.Throws<ArgumentException>("fileId", () => new HostedFileContent(string.Empty)); 17Assert.Throws<ArgumentException>("fileId", () => new HostedFileContent(" ")); 24HostedFileContent c = new(fileId); 39HostedFileContent c = new("id123"); 63var content = new HostedFileContent("file123"); 75HostedFileContent c = new("id123"); 97HostedFileContent c = new("id123"); 109HostedFileContent c = new("id123") { MediaType = mediaType }; 116HostedFileContent c = new("id123"); 132HostedFileContent c = new("id123"); 145HostedFileContent c = new("id123"); 160HostedFileContent c = new("id123"); 173HostedFileContent c = new("id123"); 188var content = new HostedFileContent("file123") 226HostedFileContent c = new("id123") { MediaType = mediaType }; 233HostedFileContent c = new("id123");
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Tools\HostedCodeInterpreterToolTests.cs (1)
47new HostedFileContent("id123"),
Microsoft.Extensions.AI.Tests (18)
ChatCompletion\OpenTelemetryChatClientTests.cs (3)
412new HostedFileContent("file-abc123"), 428yield return new() { Contents = [new HostedFileContent("file-abc123")] }; 448new HostedFileContent("file-xyz789"),
Files\LoggingHostedFileClientTests.cs (5)
61Task.FromResult(new HostedFileContent("file-123") { Name = "test.txt" }), 170Task.FromResult<HostedFileContent?>(new HostedFileContent("file-456") { Name = "report.pdf" }), 233yield return new HostedFileContent("file-1") { Name = "a.txt" }; 234yield return new HostedFileContent("file-2") { Name = "b.txt" }; 510yield return new HostedFileContent("file-1");
Files\OpenTelemetryHostedFileClientTests.cs (10)
41Task.FromResult(new HostedFileContent("file-abc") { Name = "test.txt", SizeInBytes = 1024 }), 134Task.FromResult<HostedFileContent?>(new HostedFileContent("file-info") { Name = "report.pdf", SizeInBytes = 2048 }), 188yield return new HostedFileContent("file-1") { Name = "a.txt" }; 189yield return new HostedFileContent("file-2") { Name = "b.txt" }; 190yield return new HostedFileContent("file-3") { Name = "c.txt" }; 312yield return new HostedFileContent("file-1"); 367Task.FromResult(new HostedFileContent("file-1")), 499Task.FromResult(new HostedFileContent("file-1")), 537Task.FromResult(new HostedFileContent("file-1")), 574Task.FromResult(new HostedFileContent("file-1")),
162 references to HostedFileContent
Microsoft.Extensions.AI (15)
Common\OtelMessageSerializer.cs (1)
112case HostedFileContent fc:
Files\LoggingHostedFileClient.cs (7)
59public override async Task<HostedFileContent> UploadAsync( 79var result = await base.UploadAsync(content, mediaType, fileName, options, cancellationToken).ConfigureAwait(false); 144public override async Task<HostedFileContent?> GetFileInfoAsync( 161var result = await base.GetFileInfoAsync(fileId, options, cancellationToken).ConfigureAwait(false); 190public override async IAsyncEnumerable<HostedFileContent> ListFilesAsync( 205IAsyncEnumerator<HostedFileContent> e; 223HostedFileContent? file = null;
Files\OpenTelemetryHostedFileClient.cs (6)
135public override async Task<HostedFileContent> UploadAsync( 169HostedFileContent? result = null; 236public override async Task<HostedFileContent?> GetFileInfoAsync( 254HostedFileContent? result = null; 287public override async IAsyncEnumerable<HostedFileContent> ListFilesAsync( 308IAsyncEnumerator<HostedFileContent> e;
Realtime\OpenTelemetryRealtimeClientSession.cs (1)
577case HostedFileContent fc:
Microsoft.Extensions.AI.Abstractions (18)
Contents\AIContent.cs (1)
15[JsonDerivedType(typeof(HostedFileContent), typeDiscriminator: "hostedFile")]
Contents\CodeInterpreterToolCallContent.cs (1)
30/// Inputs can include various types of content such as <see cref="HostedFileContent"/> for files,
Contents\CodeInterpreterToolResultContent.cs (1)
26/// Outputs can include various types of content such as <see cref="HostedFileContent"/> for files,
Contents\HostedFileContent.cs (1)
24/// Initializes a new instance of the <see cref="HostedFileContent"/> class.
Contents\HostedVectorStoreContent.cs (1)
14/// Unlike <see cref="HostedFileContent"/> which represents a specific file that is hosted by the AI service,
Files\DelegatingHostedFileClient.cs (3)
39public virtual Task<HostedFileContent> UploadAsync( 55public virtual Task<HostedFileContent?> GetFileInfoAsync( 62public virtual IAsyncEnumerable<HostedFileContent> ListFilesAsync(
Files\HostedFileClientExtensions.cs (4)
32public static Task<HostedFileContent> UploadAsync( 59public static async Task<HostedFileContent> UploadAsync( 140/// Downloads a file referenced by a <see cref="HostedFileContent"/>. 151HostedFileContent hostedFile,
Files\IHostedFileClient.cs (4)
21/// interface can be referenced in AI requests using <see cref="HostedFileContent"/>. 44Task<HostedFileContent> UploadAsync( 76Task<HostedFileContent?> GetFileInfoAsync( 87IAsyncEnumerable<HostedFileContent> ListFilesAsync(
Tools\HostedCodeInterpreterTool.cs (1)
39/// represented via <see cref="HostedFileContent"/>. Some also support binary data, represented via <see cref="DataContent"/>.
Tools\HostedFileSearchTool.cs (1)
39/// support different kinds of inputs, for example, some might respect <see cref="HostedFileContent"/> using provider-specific file IDs,
Microsoft.Extensions.AI.Abstractions.Tests (46)
Contents\CodeInterpreterToolCallContentTests.cs (3)
61Assert.IsType<HostedFileContent>(c.Inputs[1]); 86Assert.IsType<HostedFileContent>(deserializedSut.Inputs[1]); 87Assert.Equal("file456", ((HostedFileContent)deserializedSut.Inputs[1]).FileId);
Contents\CodeInterpreterToolResultContentTests.cs (3)
62Assert.IsType<HostedFileContent>(c.Outputs[1]); 88Assert.IsType<HostedFileContent>(deserializedSut.Outputs[1]); 89Assert.Equal("result.txt", ((HostedFileContent)deserializedSut.Outputs[1]).FileId);
Contents\HostedFileContentTests.cs (20)
24HostedFileContent c = new(fileId); 39HostedFileContent c = new("id123"); 63var content = new HostedFileContent("file123"); 66var deserializedContent = JsonSerializer.Deserialize<HostedFileContent>(json, AIJsonUtilities.DefaultOptions); 75HostedFileContent c = new("id123"); 97HostedFileContent c = new("id123"); 109HostedFileContent c = new("id123") { MediaType = mediaType }; 116HostedFileContent c = new("id123"); 132HostedFileContent c = new("id123"); 145HostedFileContent c = new("id123"); 160HostedFileContent c = new("id123"); 173HostedFileContent c = new("id123"); 188var content = new HostedFileContent("file123") 207var deserialized = JsonSerializer.Deserialize<HostedFileContent>(json, AIJsonUtilities.DefaultOptions); 226HostedFileContent c = new("id123") { MediaType = mediaType }; 233HostedFileContent c = new("id123"); 260var hostedFile = Assert.IsType<HostedFileContent>(result);
Files\DelegatingHostedFileClientTests.cs (5)
31var expectedResult = new TaskCompletionSource<HostedFileContent>(); 32var expectedFile = new HostedFileContent("file-123"); 87var expectedResult = new TaskCompletionSource<HostedFileContent?>(); 88var expectedFile = new HostedFileContent("file-789") { Name = "info.txt" }; 113HostedFileContent[] expectedFiles =
Files\HostedFileClientExtensionsTests.cs (7)
34var result = await client.UploadAsync(content); 85var result = await client.UploadAsync(tempFile); 289var hostedFileContent = new HostedFileContent("file-hfc"); 308var content = new HostedFileContent("file-1"); 316await Assert.ThrowsAsync<ArgumentNullException>("hostedFile", () => client.DownloadAsync((HostedFileContent)null!)); 322var hostedFileContent = new HostedFileContent("file-scoped") { Scope = "container-42" }; 341var hostedFileContent = new HostedFileContent("file-scoped") { Scope = "container-from-content" };
TestHostedFileClient.cs (6)
21public Func<Stream, string?, string?, HostedFileClientOptions?, CancellationToken, Task<HostedFileContent>>? UploadAsyncCallback { get; set; } 25public Func<string, HostedFileClientOptions?, CancellationToken, Task<HostedFileContent?>>? GetFileInfoAsyncCallback { get; set; } 27public Func<HostedFileClientOptions?, CancellationToken, IAsyncEnumerable<HostedFileContent>>? ListFilesAsyncCallback { get; set; } 36public Task<HostedFileContent> UploadAsync( 50public Task<HostedFileContent?> GetFileInfoAsync( 56public IAsyncEnumerable<HostedFileContent> ListFilesAsync(
Tools\HostedCodeInterpreterToolTests.cs (1)
54Assert.IsType<HostedFileContent>(tool.Inputs[0]);
Tools\HostedFileSearchToolTests.cs (1)
58Assert.IsType<HostedFileContent>(tool.Inputs[1]);
Microsoft.Extensions.AI.OpenAI (11)
OpenAIChatClient.cs (1)
321case HostedFileContent fileContent:
OpenAIHostedFileClient.cs (5)
96public async Task<HostedFileContent> UploadAsync( 185public async Task<HostedFileContent?> GetFileInfoAsync( 214public async IAsyncEnumerable<HostedFileContent> ListFilesAsync( 327private static HostedFileContent ToHostedFileContent(OpenAIFile openAIFile) => 338private static HostedFileContent? ToHostedFileContent(ContainerFileResource file, string? scope)
OpenAIResponsesChatClient.cs (5)
763new(codeTool.Inputs?.OfType<HostedFileContent>().Select(f => f.FileId).ToList() is { Count: > 0 } ids ? 1370case HostedFileContent fileContent when fileContent.HasTopLevelMediaType("image"): 1374case HostedFileContent fileContent: 1467case HostedFileContent fc: 1957var hfc = new HostedFileContent(fileId) { MediaType = mimeType, RawRepresentation = output };
Microsoft.Extensions.AI.OpenAI.Tests (29)
OpenAIConversionTests.cs (1)
351var fileContent = new HostedFileContent("file-123");
OpenAIHostedFileClientIntegrationTests.cs (19)
40var uploadedFile = await _client!.UploadAsync(uploadStream, "application/jsonl", fileName, new HostedFileClientOptions { Purpose = "fine-tune" }); 71var fileInfo = await _client.GetFileInfoAsync(uploadedFile.FileId); 94var uploadedFile = await _client!.UploadAsync(uploadStream, "text/plain", fileName, new HostedFileClientOptions { Purpose = "assistants" }); 97var files = new List<HostedFileContent>(); 98await foreach (var file in _client.ListFilesAsync(new HostedFileClientOptions { Purpose = "assistants" })) 126var uploadedFile = await _client!.UploadAsync(uploadStream, "text/plain", fileName, new HostedFileClientOptions { Purpose = "assistants" }); 129var fileInfo = await _client.GetFileInfoAsync(uploadedFileId); 163var fileInfo = await _client!.GetFileInfoAsync("file-nonexistent000000000000"); 179var uploadedFile = await _client!.UploadAsync(dataContent, new HostedFileClientOptions { Purpose = "assistants" }); 208var uploadedFile = await _client!.UploadAsync(uploadStream, "application/jsonl", fileName, new HostedFileClientOptions { Purpose = "fine-tune" }); 238var uploadedFile = await _client!.UploadAsync(uploadStream, "application/jsonl", fileName, new HostedFileClientOptions { Purpose = "fine-tune" }); 300var uploadedFile = await containerClient.UploadAsync( 309var files = new List<HostedFileContent>(); 310await foreach (var file in containerClient.ListFilesAsync(new HostedFileClientOptions { Scope = containerId })) 318var fileInfo = await containerClient.GetFileInfoAsync(uploadedFile.FileId, new HostedFileClientOptions { Scope = containerId }); 367var containerFiles = new List<HostedFileContent>(); 368await foreach (var file in fileClient.ListFilesAsync(new HostedFileClientOptions { Scope = containerId })) 376var firstFile = containerFiles[0]; 417var uploadedFile = await fileClient.UploadAsync(
OpenAIHostedFileClientTests.cs (9)
112var result = await client.UploadAsync(stream); 149var result = await client.UploadAsync(stream, options: new HostedFileClientOptions { Purpose = "fine-tune" }); 201var result = await client.GetFileInfoAsync("file-abc123"); 220var result = await client.GetFileInfoAsync("file-nonexistent"); 662var result = await client.UploadAsync(contentStream, "text/csv", "data.csv", new HostedFileClientOptions { Scope = "ctr-123" }); 743var result = await client.GetFileInfoAsync("cfile-1", new HostedFileClientOptions { Scope = "ctr-123" }); 758var result = await client.GetFileInfoAsync("cfile-nonexistent", new HostedFileClientOptions { Scope = "ctr-123" }); 846var result = await client.GetFileInfoAsync("cfile-1"); 872var result = await client.UploadAsync(contentStream, "text/csv", "data.csv", new HostedFileClientOptions
Microsoft.Extensions.AI.Stabilization.Tests (27)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolCallContentTests.cs (3)
61Assert.IsType<HostedFileContent>(c.Inputs[1]); 86Assert.IsType<HostedFileContent>(deserializedSut.Inputs[1]); 87Assert.Equal("file456", ((HostedFileContent)deserializedSut.Inputs[1]).FileId);
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolResultContentTests.cs (3)
62Assert.IsType<HostedFileContent>(c.Outputs[1]); 88Assert.IsType<HostedFileContent>(deserializedSut.Outputs[1]); 89Assert.Equal("result.txt", ((HostedFileContent)deserializedSut.Outputs[1]).FileId);
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\HostedFileContentTests.cs (20)
24HostedFileContent c = new(fileId); 39HostedFileContent c = new("id123"); 63var content = new HostedFileContent("file123"); 66var deserializedContent = JsonSerializer.Deserialize<HostedFileContent>(json, AIJsonUtilities.DefaultOptions); 75HostedFileContent c = new("id123"); 97HostedFileContent c = new("id123"); 109HostedFileContent c = new("id123") { MediaType = mediaType }; 116HostedFileContent c = new("id123"); 132HostedFileContent c = new("id123"); 145HostedFileContent c = new("id123"); 160HostedFileContent c = new("id123"); 173HostedFileContent c = new("id123"); 188var content = new HostedFileContent("file123") 207var deserialized = JsonSerializer.Deserialize<HostedFileContent>(json, AIJsonUtilities.DefaultOptions); 226HostedFileContent c = new("id123") { MediaType = mediaType }; 233HostedFileContent c = new("id123"); 260var hostedFile = Assert.IsType<HostedFileContent>(result);
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Tools\HostedCodeInterpreterToolTests.cs (1)
54Assert.IsType<HostedFileContent>(tool.Inputs[0]);
Microsoft.Extensions.AI.Tests (16)
Files\LoggingHostedFileClientTests.cs (5)
170Task.FromResult<HostedFileContent?>(new HostedFileContent("file-456") { Name = "report.pdf" }), 230static async IAsyncEnumerable<HostedFileContent> GetFilesAsync() 242await foreach (var file in client.ListFilesAsync()) 507static async IAsyncEnumerable<HostedFileContent> ThrowOnSecondItem() 521await foreach (var file in client.ListFilesAsync())
Files\OpenTelemetryHostedFileClientTests.cs (5)
134Task.FromResult<HostedFileContent?>(new HostedFileContent("file-info") { Name = "report.pdf", SizeInBytes = 2048 }), 185static async IAsyncEnumerable<HostedFileContent> GetFilesAsync() 198await foreach (var file in client.ListFilesAsync(new HostedFileClientOptions { Purpose = "assistants", Scope = "container-4" })) 309static async IAsyncEnumerable<HostedFileContent> ThrowOnSecondItem() 323await foreach (var file in client.ListFilesAsync())
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestHostedFileClient.cs (6)
21public Func<Stream, string?, string?, HostedFileClientOptions?, CancellationToken, Task<HostedFileContent>>? UploadAsyncCallback { get; set; } 25public Func<string, HostedFileClientOptions?, CancellationToken, Task<HostedFileContent?>>? GetFileInfoAsyncCallback { get; set; } 27public Func<HostedFileClientOptions?, CancellationToken, IAsyncEnumerable<HostedFileContent>>? ListFilesAsyncCallback { get; set; } 36public Task<HostedFileContent> UploadAsync( 50public Task<HostedFileContent?> GetFileInfoAsync( 56public IAsyncEnumerable<HostedFileContent> ListFilesAsync(