microsoft / teams-ai

SDK focused on building AI based applications and extensions for Microsoft Teams and other Bot Framework channels
MIT License
407 stars 176 forks source link

[PY] feat: do_action #1810

Closed BMS-geodev closed 2 months ago

BMS-geodev commented 3 months ago

Linked issues

closes: #1778

Change details

This PR focuses on adding do_action functionality to ai.py. This method is present in the JS teams-ai package.

In addition, test_ai.py was created and added to the python tests directory to provide some coverage of the ai.py methods. Specifically however, this PR's test_ai.py work only covers the new do_action method.

code snippets:

screenshots:

Attestation Checklist

Additional information

Feel free to add other relevant information below

BMS-geodev commented 3 months ago

right off the bat I'm curious about the "handler" return as seen in the js version.

        const handler = this._actions.get(action)!.handler;
        return await handler(context, state, parameters, action);

I don't think I'm properly managing the handler in the python

        handler = self._actions[action].handler
        return await handler(context, state, parameters, action)
BMS-geodev commented 3 months ago

also need to find a way this can be used / tested.

BMS-geodev commented 2 months ago

I reviewed the /teams/ai/actions scripts. I think changing this

        handler = self._actions[action].handler
        return await handler(context, state, parameters, action)

to

        action_entry = self._actions[action]
        handler = action_entry.func
        return await handler(ActionTurnContext(action, parameters, context), state)

more appropriately captures how the action handler wants to be invoked.

BMS-geodev commented 2 months ago

@lilyydu
I think I hit all the comments. Any other tests you think I should add? Also is test_ai.py in the correct place?

BMS-geodev commented 2 months ago

(I did not dismiss anything, that seemed automatic as I made changes after you accepted)