Skip to content

Commit d79e2bb

Browse files
Update README.md
update text moderation example at readme file
1 parent 10a52e8 commit d79e2bb

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

README.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -176,25 +176,28 @@ Scan and moderate text content for unsafe, inappropriate, or policy-violating ma
176176
$WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
177177
// --------------------
178178

179-
$textModerationRequest = new CopyleaksTextModerationRequestModel(
180-
"This is some text to scan.", // text
181-
true, // sandbox mode
182-
"en", // language
183-
[
184-
["id" => "adult-v1"],
185-
["id" => "toxic-v1"],
186-
["id" => "violent-v1"],
187-
["id" => "profanity-v1"],
188-
["id" => "self-harm-v1"],
189-
["id" => "harassment-v1"],
190-
["id" => "hate-speech-v1"],
191-
["id" => "drugs-v1"],
192-
["id" => "firearms-v1"],
193-
["id" => "cybersecurity-v1"]
194-
] // labels
195-
);
196-
197-
$response = $this->copyleaks->textModerationClient->submitText($authToken, time(), $textModerationRequest);
179+
var labelsArray = new CopyleaksTextModerationLabel[]
180+
{
181+
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.ADULT_V1),
182+
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.TOXIC_V1),
183+
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.VIOLENT_V1),
184+
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.PROFANITY_V1),
185+
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.SELF_HARM_V1),
186+
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.HARASSMENT_V1),
187+
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.HATE_SPEECH_V1),
188+
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.DRUGS_V1),
189+
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.FIREARMS_V1),
190+
new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.CYBERSECURITY_V1)
191+
};
192+
193+
var model = new CopyleaksTextModerationRequestModel(
194+
text: "This is some text to scan.",
195+
sandbox: true,
196+
language: CopyleaksTextModerationLanguages.ENGLISH,
197+
labels: labelsArray
198+
);
199+
200+
$response = $this->copyleaks->textModerationClient->submitText($authToken, time(), $model);
198201
$textModerationResponse= CopyleaksTextModerationResponseModel::fromArray(json_decode(json_encode($response), true));
199202

200203
$this->logInfo('Text Moderation - submitText', $textModerationResponse);

0 commit comments

Comments
 (0)