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

[Dev Support]: No citation contents in activity.entities when context.sendActivity #2307

Open
frankqianms opened this issue Feb 13, 2025 · 5 comments
Assignees
Labels
dev support Dev support tracking Python Change/fix applies to Python. If all three, use the 'JS & dotnet & Python' label

Comments

@frankqianms
Copy link

Language

Python

Version

latest

Description

I tried to rewrite SAY_COMMAND to add citations for my customized datasource RAG bot. I successfully got citation titles and contents in response. After formatting the contents and sending the activity, no citation contents included in the request body to Teams Channel.

Reproduction Steps

1.git clone: https://github.com/frankqianms/custom-datasource-py
2.Open the repo using VS Code.
3.fill in your azure openai api key, endpoint and deployment model name in `env/.env.testtool.user`
4.Start debugging with `Debug in Test Tool` option
5.Send message "Summarize Perksplus Program"
6.Line 113 in src/custom_say_command.py will print ourt message.entities with correct citation contents, but context.send_activity() will raise a request to Teams Channel without citations in message.entities.
...
@frankqianms frankqianms added the bug Something isn't working label Feb 13, 2025
@sayali-MSFT
Copy link

sayali-MSFT commented Feb 14, 2025

@frankqianms , Thank you for your inquiry about your Teams app development issue

Could you please raise a bug on this repo - https://github.com/microsoft/botbuilder-python/issues.

@lilyydu lilyydu added the Python Change/fix applies to Python. If all three, use the 'JS & dotnet & Python' label label Feb 14, 2025
@frankqianms
Copy link
Author

frankqianms commented Feb 19, 2025

@sayali-MSFT sure. here is the related issue: microsoft/botbuilder-python#2208.

@lilyydu
Copy link
Collaborator

lilyydu commented Feb 20, 2025

Hi @frankqianms,

This seems like a serialization issue. I noticed you are manually adding in the Entity

    message.entities = [{
        "type": "https://schema.org/Message",
        "@type": "Message",
        "@context": "https://schema.org",
        "@id": "",
        "additionalType": ["AIGeneratedContent"],
        **( {"citation": referenced_citations} if referenced_citations else {}) # Conditionally add citation
    }]

Instead, can you try using AIEntity? Similiar to this-

curr_citations = get_used_citations(self._message, self._citations)
            activity.entities.append(
                AIEntity(
                    additional_type=[],
                    citation=curr_citations if curr_citations else [],
                )
            )

@lilyydu lilyydu self-assigned this Feb 20, 2025
@lilyydu lilyydu added dev support Dev support tracking and removed bug Something isn't working labels Feb 21, 2025
@lilyydu lilyydu changed the title [Bug]: No citation contents in activity.entities when context.sendActivity [Dev Support]: No citation contents in activity.entities when context.sendActivity Feb 21, 2025
@frankqianms
Copy link
Author

@lilyydu No helpful of using AIEntity. Thanks

@frankqianms
Copy link
Author

@lilyydu Although AIEntity didn't work, things were different. When using AIEntity, a serializationError will occur for the entities=[AIEntity(additional_type=['AIGeneratedContent'], citation=[{'@type': 'Claim', 'position': 1, 'appearance': {'@type': 'DigitalDocument', 'name': 'Contoso Electronics PerksPlus Program', 'url': None, 'abstract': 'Introducing PerksPlus - the ultimate benefits program designed to support the health and wellness of employees. With PerksPlus, employees have the opportunity to expense up to $1000 for fitness-related programs, making it easier and more affordable to maintain a healthy lifestyle.'}}], type='https://schema.org/Message', type_='Message', context_='https://schema.org', id_='', usage_info=None)].
Error:

azure.core.exceptions.SerializationError: (
"Attribute None in object dict cannot be serialized.\n{'@type': 'Claim', 'position': 1, 'appearance': {'@type': 'DigitalDocument', 'name': 'Contoso Electronics PerksPlus Program', 'url': None, 'abstract': 'Introducing PerksPlus - the ultimate benefits program designed to support the health and wellness of employees. With PerksPlus, employees have the opportunity to expense up to $1000 for fitness-related programs, making it easier and more affordable to maintain a healthy lifestyle.'}},
AttributeError: 'dict' object has no attribute '_attribute_map'",
AttributeError("'dict' object has no attribute '_attribute_map'")
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev support Dev support tracking Python Change/fix applies to Python. If all three, use the 'JS & dotnet & Python' label
Projects
None yet
Development

No branches or pull requests

3 participants