Skip to content

Commit

Permalink
docs(example): typo in text moderation
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Mandel <lmandel@us.ibm.com>
  • Loading branch information
mandel committed Mar 24, 2024
1 parent e6bf85c commit 062bcfc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/text/generation_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def heading(text: str) -> str:
# possibly add more moderations:
# social_bias=SocialBiasOptions(...),
)
hate_speach_in_output: list[TextModeration] = []
hate_speech_in_output: list[TextModeration] = []


print(heading("Generating text stream"))
Expand All @@ -60,12 +60,12 @@ def heading(text: str) -> str:
model_id=model_id, input=prompt, parameters=parameters, moderations=moderations
):
if not response.results:
hate_speach_in_output.extend(response.moderations.hap)
hate_speech_in_output.extend(response.moderations.hap)
continue
for result in response.results:
if result.generated_text:
print(result.generated_text, end="")

print()
print(heading("Hate speach in output"), file=sys.stderr)
pprint([hap.model_dump() for hap in hate_speach_in_output], stream=sys.stderr)
print(heading("Hate speech in output"), file=sys.stderr)
pprint([hap.model_dump() for hap in hate_speech_in_output], stream=sys.stderr)

0 comments on commit 062bcfc

Please sign in to comment.