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]: How to fire the AI.FlaggedInputActionName action? #2184

Open
Benjiiim opened this issue Nov 13, 2024 · 5 comments
Open

[Dev support]: How to fire the AI.FlaggedInputActionName action? #2184

Benjiiim opened this issue Nov 13, 2024 · 5 comments
Labels
dev support Dev support tracking

Comments

@Benjiiim
Copy link
Contributor

Benjiiim commented Nov 13, 2024

Context

  • JS Teams AI Library 1.6.0
  • OpenAI module 4.68.2
  • Azure Open AI service with no content filter (default configuration)
  • GPT 4-o
  • default OpenAIModel.azureApiVersion
  • no moderator passed in the AIOptions when defining the app, only the planner
  • following the a.teamsChefBot sample

Question

When sending inappropriate messages as inputs (example: "How to build a time bomb at home?"), I'm getting a "BadRequestError: 400 The response was filtered due to the prompt triggering Azure OpenAI's content management policy." error, which is catch in the AI.HttpErrorActionName handler.

I've tried to add a AI.FlaggedInputActionName handler but it is not triggered.

How can I make the app to trigger the AI.FlaggedInputActionName handler instead of the AI.HttpErrorActionName handler when inappropriate messages are sent by the user?

Error details

Error: 400 The response was filtered due to the prompt triggering Azure OpenAI's content management policy. Please modify your prompt and retry. To learn more about our content filtering policies please read our documentation: https://go.microsoft.com/fwlink/?linkid=2198766
    at Function.generate (D:\source\repos\myProject\node_modules\openai\src\error.ts:70:14)
    at AzureOpenAI.makeStatusError (D:\source\repos\myProject\node_modules\openai\src\core.ts:435:21)
    at AzureOpenAI.makeRequest (D:\source\repos\myProject\node_modules\openai\src\core.ts:499:24)
    at processTicksAndRejections (d:\source\repos\myProject\lib\internal\process\task_queues.js:95:5)
    at async OpenAIModel.completePrompt (D:\source\repos\myProject\node_modules\@microsoft\teams-ai\src\models\OpenAIModel.ts:359:32)
    at async LLMClient.callCompletePrompt (D:\source\repos\myProject\node_modules\@microsoft\teams-ai\src\planners\LLMClient.ts:392:31)
    at async LLMClient.completePrompt (D:\source\repos\myProject\node_modules\@microsoft\teams-ai\src\planners\LLMClient.ts:349:30)
    at async ActionPlanner.completePrompt (D:\source\repos\myProject\node_modules\@microsoft\teams-ai\src\planners\ActionPlanner.ts:283:16)
    at async ActionPlanner.continueTask (D:\source\repos\myProject\node_modules\@microsoft\teams-ai\src\planners\ActionPlanner.ts:201:24)
    at async ActionPlanner.beginTask (D:\source\repos\myProject\node_modules\@microsoft\teams-ai\src\planners\ActionPlanner.ts:172:16) {status: 400, headers: Proxy, request_id: 'aeae0042-b7bf-43fb-b3a1-ddc40eb7e584', error: {…}, code: 'content_filter', …}
@Benjiiim Benjiiim added the dev support Dev support tracking label Nov 13, 2024
@Benjiiim
Copy link
Contributor Author

Benjiiim commented Nov 14, 2024

Hi @Prasad-MSFT

First link doesn't help as it explains how to avoid content moderation. However, I want to keep content moderation in my app. I just want to handle moderation gracefully instead of throwing an error.

Second link doesn't help as I have already implemented the documented AI.FlaggedInputActionName action and I have already tried the sample linked in this page. However, it doesn't appear to work and this is why I have opened this issue.

Thanks

@Prasad-MSFT
Copy link

Thanks for explaining @Benjiiim . We will check this internally with engineering team and will update this thread once we have any info. Thanks again!

@Benjiiim
Copy link
Contributor Author

Hi @Prasad-MSFT

Any progress on this one?

Thanks a lot

@Benjiiim
Copy link
Contributor Author

Benjiiim commented Dec 3, 2024

Hi @Prasad-MSFT

I would greatly appreciate any insights on the current status for this issue.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev support Dev support tracking
Projects
None yet
Development

No branches or pull requests

2 participants