From 36505058e0aa72327dfe5d0fc436aa1d846c122e Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 4 Sep 2024 13:23:17 -0700 Subject: [PATCH] doc setting language per request --- .../docs/proxy/guardrails/pii_masking_v2.md | 65 ++++++++++++++++++- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/docs/my-website/docs/proxy/guardrails/pii_masking_v2.md b/docs/my-website/docs/proxy/guardrails/pii_masking_v2.md index 592c0e6bf2f..ff1be9c7f81 100644 --- a/docs/my-website/docs/proxy/guardrails/pii_masking_v2.md +++ b/docs/my-website/docs/proxy/guardrails/pii_masking_v2.md @@ -1,4 +1,6 @@ import Image from '@theme/IdealImage'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; # PII Masking - Presidio @@ -57,7 +59,7 @@ curl http://localhost:4000/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-1234" \ -d '{ - "model": "gpt-4o-mini", + "model": "gpt-3.5-turbo", "messages": [ {"role": "user", "content": "Hello my name is Jane Doe"} ], @@ -83,7 +85,7 @@ Expected response on failure } ], "created": 1725479980, - "model": "gpt-4o-mini-2024-07-18", + "model": "gpt-3.5-turbo-2024-07-18", "object": "chat.completion", "system_fingerprint": "fp_5bd87c427a", "usage": { @@ -104,7 +106,7 @@ curl http://localhost:4000/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-1234" \ -d '{ - "model": "gpt-4o-mini", + "model": "gpt-3.5-turbo", "messages": [ {"role": "user", "content": "Hello good morning"} ], @@ -120,10 +122,67 @@ curl http://localhost:4000/chat/completions \ ## Set `language` per request +The Presidio API [supports passing the `language` param](https://microsoft.github.io/presidio/api-docs/api-docs.html#tag/Analyzer/paths/~1analyze/post). Here is how to set the `language` per request + + + + +```shell +curl http://localhost:4000/chat/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer sk-1234" \ + -d '{ + "model": "gpt-3.5-turbo", + "messages": [ + {"role": "user", "content": "is this credit card number 9283833 correct?"} + ], + "guardrails": ["presidio-pre-guard"], + "guardrail_config": {"language": "es"} + }' +``` + + + + + + +```python + +import openai +client = openai.OpenAI( + api_key="anything", + base_url="http://0.0.0.0:4000" +) + +# request sent to model set on litellm proxy, `litellm --model` +response = client.chat.completions.create( + model="gpt-3.5-turbo", + messages = [ + { + "role": "user", + "content": "this is a test request, write a short poem" + } + ], + extra_body={ + "metadata": { + "guardrails": ["presidio-pre-guard"], + "guardrail_config": {"language": "es"} + } + } +) +print(response) +``` + + + + + + ## Output parsing ## Ad Hoc Recognizers +## Logging Only