Skip to content

Commit c561c25

Browse files
pre-commit-ci[bot]Ankur-singh
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 5573cc0 commit c561c25

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

comps/guardrails/src/polite_guard/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
## Introduction
44

5-
The Polite Guard Microservice allows AI application developers to ensure that user input and Large Language Model (LLM) outputs remain polite and respectful. By leveraging, [Polite Guard](https://huggingface.co/Intel/polite-guard), a fine-tuned Transformer model for politeness classification, this lightweight guardrails microservice ensures courteous interactions without significantly sacrificing performance, making it suitable for deployment on both Intel Gaudi and Xeon.
5+
The Polite Guard Microservice allows AI application developers to ensure that user input and Large Language Model (LLM) outputs remain polite and respectful. By leveraging, [Polite Guard](https://huggingface.co/Intel/polite-guard), a fine-tuned Transformer model for politeness classification, this lightweight guardrails microservice ensures courteous interactions without significantly sacrificing performance, making it suitable for deployment on both Intel Gaudi and Xeon.
66

7-
Politeness plays a crucial role in creating a positive and respectful environment. The service classifies text into four categories: *polite*, *somewhat polite*, *neutral*, and *impolite*. Any *impolite* text is rejected, along with a score, ensuring that systems maintain a courteous tone.
7+
Politeness plays a crucial role in creating a positive and respectful environment. The service classifies text into four categories: _polite_, _somewhat polite_, _neutral_, and _impolite_. Any _impolite_ text is rejected, along with a score, ensuring that systems maintain a courteous tone.
88

99
More details about the Polite Guard model can be found [here](https://github.com/intel/polite-guard).
1010

11-
1211
## 🚀1. Start Microservice with Python(Option 1)
1312

1413
### 1.1 Install Requirements

comps/guardrails/src/polite_guard/integrations/politeguard.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ async def invoke(self, input: str):
3232
"""
3333
response = await asyncio.to_thread(self.polite_pipeline, input)
3434
if response[0]["label"] == "impolite":
35-
return TextDoc(text=f"Violated policies: Impolite (score: {response[0]['score']:0.2f}), please check your input.", downstream_black_list=[".*"])
35+
return TextDoc(
36+
text=f"Violated policies: Impolite (score: {response[0]['score']:0.2f}), please check your input.",
37+
downstream_black_list=[".*"],
38+
)
3639
else:
3740
return TextDoc(text=input)
3841

0 commit comments

Comments
 (0)