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.

Azure Computer Vision
Azure Computer Vision
An Azure artificial intelligence service that analyzes content in images and video.
332 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,062 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,522 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 47,676 Reputation points
    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