AttributeError: 'FileCitation' object has no attribute 'quote' in Message Annotations

Peng Ye 25 Reputation points
2024-11-27T03:09:35.3+00:00

I encountered an AttributeError while trying to gather citations based on annotation attributes in my code. Here is the relevant section of the code:

# Gather citations based on annotation attributes   
if (file_citation := getattr(annotation, 'file_citation', None)):   
    cited_file = client.files.retrieve(file_citation.file_id)   
    citations.append(f'[{index}] {**file_citation.quote**} from {cited_file.filename}')

When attempting to access file_citation.quote, I receive the following error message:

(Pdb) file_citation.quote
*** AttributeError: 'FileCitation' object has no attribute 'quote'

Can anyone help identify why this error is occurring and how to resolve it?

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,377 questions
{count} votes

Accepted answer
  1. navba-MSFT 26,245 Reputation points Microsoft Employee
    2024-11-28T05:54:01.6466667+00:00

    @Peng Ye Unfortunately, from the Azure OpenAI perspective there is no workaround to achieve this.
    .

    However, there is a complex workaround, to achieve this using Azure AI Search with explicit field mappings can definitely help you retrieve citations and quotes. By defining the data path between source fields and target fields in the search index, you can ensure that the enriched output is correctly mapped to the fields you need, such as title, URL, and filepath.

    .

    Here’s a general outline of how you can set this up:

    Define the Data Path:

    • Map the source fields (e.g., content, metadata) to the target fields in your search index.
    • Ensure that the enriched output (e.g., extracted quotes, citations) is mapped to specific fields in the search index.

    Set Up Explicit Field Mappings:

    • Use the Azure AI Search indexer to define explicit field mappings.
    • Map the enriched output fields to the corresponding fields in the search index.

    Verify the Configuration:

    • Check the search index to ensure that the fields (title, URL, filepath) are populated correctly.
    • Test the search functionality to retrieve the citations and quotes based on the indexed data.

    . Here’s an example of how you might configure the field mappings in your indexer:

    enter image description here

    By setting up these mappings, you can ensure that the enriched data is correctly indexed and can be retrieved for generating citations and quotes.

    • Field Mappings in Indexers: This documentation explains how to set explicit field mappings that establish the data path between source fields in a supported data source and target fields in a search index.
    • Map Enriched Output to Fields in a Search Index: This article explains how to set up output field mappings, defining a data path between in-memory data generated during skillset processing and target fields in a search index.

    Hope this helps.

    **

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.