Skip to content
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

'FileCitation' object has no attribute 'quote' #1498

Open
1 task done
esseti opened this issue Jun 21, 2024 · 4 comments
Open
1 task done

'FileCitation' object has no attribute 'quote' #1498

esseti opened this issue Jun 21, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@esseti
Copy link

esseti commented Jun 21, 2024

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • 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

  1. Create an assistant with files associated
  2. ask a question that has filecitation
  3. check to get the file_citation.quote

Code snippets

No response

OS

macOs

Python version

3.12

Library version

1.30.5

@esseti esseti added the bug Something isn't working label Jun 21, 2024
@dgellow
Copy link
Contributor

dgellow commented Jun 21, 2024

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:

  1. Try again with the latest version of the SDK
  2. Provide a minimal project we could use to try to reproduce the problem?

@hirayu
Copy link

hirayu commented Jul 10, 2024

I am getting the same error. It seems quote was removed from FileCitation on v1.34.0.
#1481

@hirayu
Copy link

hirayu commented Jul 18, 2024

related discussion:
openai/openai-openapi#263 (comment)

we just rolled out a fix to remove quote from the openapi spec and will roll out updated sdks shortly.

@eirikora
Copy link

eirikora commented Sep 12, 2024

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'`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants