LoslegenKostenlos loslegen

Moderating the customer call

To ensure quality and safety, you'll now moderate the processed customer message. This step helps identify and flag potentially inappropriate content such as harassment.

The corrected transcript from the previous exercise is available as corrected_text.

Diese Übung ist Teil des Kurses

Multi-Modal Systems with the OpenAI API

Kurs anzeigen

Anleitung zur Übung

  • Create a moderation request with corrected_text as input.
  • Extract response's category scores and convert them to a dictionary using .model_dump().
  • Extract the harassment score from the scores dictionary and check if it is greater than 0.8.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

client = OpenAI(api_key="")

# Send the moderation request
response = ____

# Extract scores and convert to dictionary
scores = ____

# Extract harassment score
harassment_score = ____

if ____:
    print("Content flagged for harassment!")
else:
    print("Content is safe from harassment.")
Code bearbeiten und ausführen