question

2JK avatar image
0 Votes"
2JK asked 2JK edited

Async with content moderation and computer vision client python

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-cognitive-servicesazure-computer-visionazure-content-moderator
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YutongTie-MSFT avatar image
0 Votes"
YutongTie-MSFT answered 2JK edited

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://docs.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://docs.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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the answer. But what I meant is, I want asynchronous Content Moderator and Computer Vision clients similar to the text analytics aio client, which I'm aware works and have successfully tried. The code sample I provided uses the Content Moderator client which, as far as I can tell, does not have an asynchronous client. Unless there is a workaround.

Apologies for not making myself clearer.

0 Votes 0 ·