microsoft / teams-ai

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

[Dev support]: Why does the app.messageExtensions.query handler use `Query<TParams>` instead of a `MessageExtensionQuery` type? #1628

Closed therealjohn closed 3 weeks ago

therealjohn commented 2 months ago

Question

Code snippets

https://github.com/microsoft/teams-ai/blob/main/js/packages/teams-ai/src/MessageExtensions.ts#L317

This makes it harder to re-use existing code or autocomplete for understanding what comes from the query. For example, the MessageExtensionQuery type in the Bot Framework SDK has clear properties for parameters that make it simpler to learn the API.

image

Compared to this in the AI SDK makes it difficult to use:

app.messageExtensions.query("searchCmd", async (context, state, query) => {
  const searchQuery = query.parameters.queryText;
  // Other handling
  // e.g. Create search / action cards
corinagum commented 2 months ago

@therealjohn We flatten the object from MessageExtensionQuery later in the code: https://github.com/microsoft/teams-ai/blob/main/js/packages/teams-ai/src/MessageExtensions.ts#L333 but I'm not recalling why.

@Stevenic do you have insight on this? I realize it was a decision made a while ago at this point, but it would be good to know if there's reasons to avoid switching to MessageExtensionQuery

Stevenic commented 1 month ago

@therealjohn we were trying to unify all of the various query structures across the SDK. There are 2 or 3 different patterns that basically do the same thing so the goal was to get that down to one unified pattern. You're still free to ignore our unified query parameter and just use the activity directly.

Can you elaborate on the intelisense issues as that shouldn't really be impacted.

corinagum commented 3 weeks ago

Closing as answered. Please feel free to add info on discussions held in chat for other developers' info.