Shall we support Powered by AI and feedback loop feature in Python SDK?
Use this query to search for the most popular feature requests.
Is your feature request related to a problem? Please describe. As Teams channel support a 'AI generated' tag as new feature Powered by AI, it is better for Python SDK to support it, along with citations and feedback loop. I think the problem is that entities are missing when constructing the post body in this file. https://github.com/microsoft/botbuilder-python/blob/01449b5a9f33f55297e420c1c0cc2403c63ad67c/libraries/botframework-connector/botframework/connector/aio/operations_async/_conversations_operations_async.py#L517
teams-ai Python library already support these new features, need your support to accomplish them.
Cc. @tracyboehrer @aacebo
@frankqianms When citations are added to BF SDK, it will be across all languages. This work just hasn't happened yet.
@tracyboehrer Are citations and AI labels now available in all languages? Where can I find sample code for Python? I haven't been able to get it to work.
ai_entity = { "type": "https://schema.org/Message", "@type": "Message", "@context": "https://schema.org", "additionalType": ["AIGeneratedContent"], } send_response = await turn_context.send_activity( Activity( type=ActivityTypes.message, text="Hey I'm a friendly AI bot. This message is generated through AI", entities=[ai_entity] ) )
@maaisde The problem is that you can not just construct an entity by using simple dict type. You need to use botbuilder.schema.Entity to construct your entity obj. Codes like that.
from botbuilder.schema import Entity
message.entities = [Entity(additional_type=["AIGeneratedContent"])]
Thanks @frankqianms
I also tried that on my first attempts.
The problem is that when I try this I am getting the following error.
additional_type is not a known attribute of class <class 'botbuilder.schema._models_py3.Entity'> and will be ignored
or
additionalType is not a known attribute of class <class 'botbuilder.schema._models_py3.Entity'> and will be ignored
What confuses me is that the javascript example also doesn't use the entity object. Javascript example:
await context.sendActivity({
type: ActivityTypes.Message,
text: `Hey! I'm a friendly AI bot. This message is generated by AI.`,
entities: [
{
type: "https://schema.org/Message",
"@type": "Message",
"@context": "https://schema.org",
additionalType: ["AIGeneratedContent"], // Enables AI label
}
]
});
@maaisde I'm sorry! You are right! the Entity type only has a type parameter in its __init__ method and _attribute_map. We need to create another class based on Entity to add additional_type as an attribute, such as AIEntity. Look at the codes.
@dataclass
class AIEntity(Entity):
_attribute_map = {
"type": {"key": "type", "type": "str"},
"type_": {"key": "@type", "type": "str"},
"context_": {"key": "@context", "type": "str"},
"id_": {"key": "@id", "type": "str"},
"additional_type": {"key": "additionalType", "type": "[str]"},
}
additional_type: Optional[list[str]]
type: str = "https://schema.org/Message"
type_: str = "Message"
context_: str = "https://schema.org"
id_: str = ""
message.entities = [AIEntity(additional_type=["AIGeneratedContent"])]
As for differences between JS and Python, I think @tracyboehrer can provide more insights of the design.
Thank you @frankqianms for pointing this out! I would never have thought of creating a custom class inheriting from Entity just to add the additional_type attribute and the correct attribute map for Teams AI labeling. This approach works perfectly.
Maybe this could be added to the Python SDK in the future? It would make it much easier for others to implement Teams AI features without having to reverse-engineer the serialization details.
Thanks again for the clarification!

@maaisde You're welcome!