Async with content moderation and computer vision client python

2JK 241 Reputation points
2021-08-30T16:01:26.74+00:00

Hi.

Is there an asynchronous way to use the Content Moderation and Computer Vision clients? I need something similar to the Text Analytics client, where you can reference the TA client from azure.ai.textanalytics.aio. This predictably throws an exception:

async with cm_client:
     screen = await cm_client.text_moderation.screen_text(text_content_type="text/plain", text_content=io.BytesIO(sentence.encode()), 
                            language="eng", pii=True, classify=True
      )

Same for the CV client. Is there a workaround or is this just not supported in these clients?

Thanks.

Community Center | Not monitored
Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform

Azure Vision in Foundry Tools
0 comments No comments

1 answer

Sort by: Most helpful
  1. YutongTie-9091 54,031 Reputation points Moderator
    2021-08-31T03:44:57.267+00:00

    Hello,

    Text Analytics client is workable. Probably reason for the issue is not installing the client well and not import the class correctly.

    Could you please check:

    1. Install : https://learn.microsoft.com/en-us/azure/cognitive-services/text-analytics/quickstarts/client-libraries-rest-api?tabs=version-3-2&pivots=programming-language-csharp#setting-up
    2. import as the code sample: https://learn.microsoft.com/en-us/python/api/azure-ai-textanalytics/azure.ai.textanalytics.aio.textanalyticsclient?view=azure-python

    If you still suffer from any error, could you please share your error details to us?

    Regards,
    Yutong

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.