Repository navigation
fix(openai): map the file citations of the code interpreter - #1060
Open
skybleak333 wants to merge 1 commit into
Open
skybleak333 wants to merge 1 commit into
skybleak333 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When the code interpreter writes a file (a chart, a CSV), OpenAI annotates the text that mentions it with a
container_file_citation, or afile_pathon older models.CitationsMapperonly knewfile_citationandurl_citationand threw for anything else, soasText()andasStructured()failed withInvalidArgumentException: Unknown citation source type: container_file_citation, after OpenAI had already run and billed the request.Both types are now mapped to a
Documentcitation, with the file name (or the file id forfile_path) as the source and the ids inadditionalContent(containerId,fileId), which is what the containers and files APIs need to download the file. When the message goes back in a later request, they're sent as the type they came in as, not as aurl_citation. An annotation type the mapper doesn't know is skipped, so a new one won't fail a response that was already produced.The four annotation types are the ones in the official SDK (
openai-python,types/responses/response_output_text.py).New tests: the mapper round trip for both types, an unknown type being skipped, and a code interpreter response with a
container_file_citationthroughasText(). All four fail without the change. The full suite, PHPStan, Pint and Rector pass.