A developer built a Python prototype that uses the OpenAI Python library and the Responses API to remove personal details from customer emails. Testing shows that two calls with the same email can return slightly different wording and formatting. A downstream system needs consistent, structured output from every call: the redacted text and a list of the entities found, with each entity's category.
What should the developer change the application to do?
Generative models called through the Responses API can return different wording or formatting for the same prompt because they generate text probabilistically. When an application needs consistent, structured values such as redacted text, the Azure Language SDK is the better choice. Its recognize_pii_entities() method returns the redacted text and a list of the entities found, with each entity's category and confidence score.
- Not correct: Call
client.responses.create()by using a larger model deployment. The Responses API still sends prompts to a generative model whose results can vary between calls because it generates text probabilistically, so it does not address the need for consistent, structured output. - Correct: Call
recognize_pii_entities()by using the Azure Language SDK. The Azure Language SDK is recommended when an app needs consistent, structured values such as redacted text, and this method returns the redacted text plus a list of entities with their categories. - Not correct: Call
analyze_sentiment()by using the Azure Language SDK. This method classifies sentiment as positive, negative, neutral or mixed; it does not return redacted text or PII entities. - Not correct: Call
detect_language()by using the Azure Language SDK. This method returns the detected language, ISO code and confidence score; it does not return redacted text or PII entities.