mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
proxy server
This commit is contained in:
parent
7cac1b0dce
commit
21963e0bbe
1 changed files with 34 additions and 0 deletions
|
|
@ -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)
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="sdk" label="LiteLLM SDK">
|
||||
|
||||
```python
|
||||
from litellm import completion
|
||||
|
||||
|
|
@ -389,7 +392,38 @@ response = completion(
|
|||
},
|
||||
)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="proxy" label="LiteLLM Proxy Server">
|
||||
|
||||
```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)
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Usage - "Assistant Pre-fill"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue