From 21963e0bbe788af05533f872fcae3727ca1ae63a Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 29 Jul 2024 14:22:02 -0700 Subject: [PATCH] proxy server --- docs/my-website/docs/providers/bedrock.md | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/my-website/docs/providers/bedrock.md b/docs/my-website/docs/providers/bedrock.md index 08a4d4862d5..1ba67955567 100644 --- a/docs/my-website/docs/providers/bedrock.md +++ b/docs/my-website/docs/providers/bedrock.md @@ -365,6 +365,9 @@ print(f"\nResponse: {resp}") Example of using [Bedrock Guardrails with LiteLLM](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-use-converse-api.html) + + + ```python from litellm import completion @@ -389,7 +392,38 @@ response = completion( }, ) ``` + + +```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="anthropic.claude-v2", messages = [ + { + "role": "user", + "content": "this is a test request, write a short poem" + } +], +temperature=0.7, +extra_body={ + guardrailConfig={ + "guardrailIdentifier": "ff6ujrregl1q", # The identifier (ID) for the guardrail. + "guardrailVersion": "DRAFT", # The version of the guardrail. + "trace": "disabled", # The trace behavior for the guardrail. Can either be "disabled" or "enabled" + }, +} +) + +print(response) +``` + + ## Usage - "Assistant Pre-fill"