'FileCitation' object has no attribute 'quote'
Confirm this is an issue with the Python library and not an underlying OpenAI API
- [X] This is an issue with the Python library
Describe the bug
After the last update i've tried to use my code that does what explained also here. https://platform.openai.com/docs/assistants/how-it-works/managing-threads-and-messages
Now when accessing the .quote i receive the error as above
'FileCitation' object has no attribute 'quote'.
can it be that they changed the api? (i don't find annotations description in the docs)
To Reproduce
- Create an assistant with files associated
- ask a question that has filecitation
- check to get the file_citation.quote
Code snippets
No response
OS
macOs
Python version
3.12
Library version
1.30.5
Hi @esseti,
Thanks for reporting the issue. That's pretty odd, quote is defined on the model and should be None if the server doesn't include it in its response:
class FileCitation(BaseModel):
file_id: Optional[str] = None
"""The ID of the specific File the citation is from."""
quote: Optional[str] = None
"""The specific quote in the file."""
You shouldn't get the error you mentioned.
Could you please:
- Try again with the latest version of the SDK
- Provide a minimal project we could use to try to reproduce the problem?
I am getting the same error. It seems quote was removed from FileCitation on v1.34.0.
https://github.com/openai/openai-python/pull/1481
related discussion: https://github.com/openai/openai-openapi/issues/263#issuecomment-2163570333
we just rolled out a fix to remove quote from the openapi spec and will roll out updated sdks shortly.
I see the same error and know that the OpenAI assistant I use sometimes returns None as quote. These None values seem to have appeared for Word documents we loaded into a vector store using a python script that sent these in through the OpenAI API.
Here is the bottom of my traceback: /mount/src/gpt-testbed-api-ui/app.py:85 in on_text_done
82 │
83 │ @override
84 │ def on_text_done(self, text):
85 │ │ format_text = format_annotation(text) <<<
86 │ │ st.session_state.current_markdown.markdown(format_text, True)
87 │ │ st.session_state.chat_log.append({"name": "assistant", "msg":
88
/mount/src/gpt-testbed-api-ui/app.py:197 in format_annotation
194 │ │ if file_citation := getattr(annotation, "file_citation", None)
195 │ │ │ cited_file = client.files.retrieve(file_citation.file_id)
196 │ │ │ citations.append(
197 │ │ │ │ f"[{index}] {file_citation.quote} from {cited_file.fil <<<
198 │ │ │ )
199 │ │ elif file_path := getattr(annotation, "file_path", None):
200 │ │ │ link_tag = create_file_link(
/home/adminuser/venv/lib/python3.12/site-packages/pydantic/main.py:853 in
getattr
850 │ │ │ │ │ │ return super().__getattribute__(item) # Rais
851 │ │ │ │ │ else:
852 │ │ │ │ │ │ # this is the current error
853 │ │ │ │ │ │ raise AttributeError(f'{type(self).__name__!r <<<
854 │ │
855 │ │ def __setattr__(self, name: str, value: Any) -> None:
856 │ │ │ if name in self.__class_vars__:
──────────────────────────────────────────────────────────────────────────────── AttributeError: 'FileCitation' object has no attribute 'quote'`