-
Notifications
You must be signed in to change notification settings - Fork 342
Add ContainerFileCitationMessageAnnotation
#792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
GetContainerFileContentandGetContainerFileContentAsynctoDownloadContainerFileandDownloadContainerFileAsync - Added
ContainerFileCitationMessageAnnotationclass 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"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
much better!
ContainerFileCitationMessageAnnotationas a class derived fromResponseMessageAnnotationContainerClient:GetContainerFileContent-->DownloadContainerFileGetContainerFileContentAsync-->DownloadContainerFileAsync