Skip to content

Conversation

@joseharriaga
Copy link
Collaborator

  • Added ContainerFileCitationMessageAnnotation as a class derived from ResponseMessageAnnotation
  • Renamed the following methods in the ContainerClient:
    • GetContainerFileContent --> DownloadContainerFile
    • GetContainerFileContentAsync --> DownloadContainerFileAsync

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR renames the GetContainerFileContent method to DownloadContainerFile in the ContainerClient API and introduces a new ContainerFileCitationMessageAnnotation type for container file citations in response messages.

  • Renamed GetContainerFileContent and GetContainerFileContentAsync to DownloadContainerFile and DownloadContainerFileAsync
  • Added ContainerFileCitationMessageAnnotation class to handle container file citations with properties for containerId, fileId, startIndex, endIndex, and filename
  • Updated tests, examples, and API surface to reflect the method rename

Reviewed Changes

Copilot reviewed 12 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Containers/ContainerTests.cs Updated test calls from GetContainerFileContentAsync to DownloadContainerFileAsync
src/Generated/OpenAIModelFactory.cs Added factory method for ContainerFileCitationMessageAnnotation
src/Generated/Models/Responses/ResponseMessageAnnotation.Serialization.cs Added deserialization case for "container_file_citation" type
src/Generated/Models/Responses/ContainerFileCitationMessageAnnotation.cs New auto-generated class for container file citation message annotations
src/Generated/Models/Responses/ContainerFileCitationMessageAnnotation.Serialization.cs New auto-generated serialization logic for container file citation annotations
src/Generated/Models/OpenAIContext.cs Registered ContainerFileCitationMessageAnnotation as ModelReaderWriterBuildable
src/Generated/ContainerClient.cs Renamed methods from GetContainerFileContent to DownloadContainerFile
src/Generated/ContainerClient.RestClient.cs Renamed internal request creation method to CreateDownloadContainerFileRequest
src/Custom/Responses/Annotations/UriCitationMessageAnnotation.cs Formatting cleanup of comments
src/Custom/Responses/Annotations/ResponseMessageAnnotationKind.cs Added ContainerFileCitation enum value with CodeGenMember attributes
src/Custom/Responses/Annotations/FilePathMessageAnnotation.cs Formatting cleanup of comments
src/Custom/Responses/Annotations/FileCitationMessageAnnotation.cs Formatting cleanup of comments
src/Custom/Responses/Annotations/ContainerFileCitationMessageAnnotation.cs Custom partial class for container file citation annotations
specification/client/containers.client.tsp Updated TypeSpec to rename GetContainerFileContent to DownloadContainerFile
specification/base/typespec/responses/models.tsp Updated TypeSpec model to extend Annotation base type and add filename property
examples/Responses/Example10_CodeInterpreterAsync.cs New async example demonstrating container file citation usage
examples/Responses/Example10_CodeInterpreter.cs New example demonstrating container file citation usage
api/OpenAI.netstandard2.0.cs Updated API surface with renamed methods
api/OpenAI.net8.0.cs Updated API surface with renamed methods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// Download the file from the container and save it.
ContainerClient containerClient = new(apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
BinaryData fileBytes = await containerClient.DownloadContainerFileAsync(containerFileCitation.ContainerId, containerFileCitation.FileId);
using FileStream stream = File.OpenWrite($"{Guid.NewGuid()}.xlsx");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the response provide any information about the expected file extension of the file, or would the caller always need to know this somehow?

Copy link
Collaborator Author

@joseharriaga joseharriaga Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension is visible in the Filename of the ContainerFileCitationMessageAnnotation. I have modified the sample to use that instead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much better!

@joseharriaga joseharriaga merged commit d30163b into main Oct 30, 2025
2 checks passed
@joseharriaga joseharriaga deleted the joseharriaga/ContainerFile branch October 30, 2025 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants