From 522f1ac7c8f44616ac5f8e69f852504ec04e35d4 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Tue, 31 Oct 2023 22:32:40 -0700 Subject: [PATCH] (docs) bedrock --- docs/my-website/docs/providers/bedrock.md | 87 ++++++++++++----------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/docs/my-website/docs/providers/bedrock.md b/docs/my-website/docs/providers/bedrock.md index 5a41e7a3a3a..d22a56846f3 100644 --- a/docs/my-website/docs/providers/bedrock.md +++ b/docs/my-website/docs/providers/bedrock.md @@ -29,11 +29,53 @@ os.environ["AWS_SECRET_ACCESS_KEY"] = "" os.environ["AWS_REGION_NAME"] = "" response = completion( - model="anthropic.claude-instant-v1", - messages=[{ "content": "Hello, how are you?","role": "user"}] + model="anthropic.claude-instant-v1", + messages=[{ "content": "Hello, how are you?","role": "user"}] ) ``` +## Usage - Streaming +```python +import os +from litellm import completion + +os.environ["AWS_ACCESS_KEY_ID"] = "" +os.environ["AWS_SECRET_ACCESS_KEY"] = "" +os.environ["AWS_REGION_NAME"] = "" + +response = completion( + model="anthropic.claude-instant-v1", + messages=[{ "content": "Hello, how are you?","role": "user"}], + stream=True +) +for chunk in response: + print(chunk) +``` + +#### Example Streaming Output Chunk +```json +{ + "choices": [ + { + "finish_reason": null, + "index": 0, + "delta": { + "content": "ase can appeal the case to a higher federal court. If a higher federal court rules in a way that conflicts with a ruling from a lower federal court or conflicts with a ruling from a higher state court, the parties involved in the case can appeal the case to the Supreme Court. In order to appeal a case to the Sup" + } + } + ], + "created": null, + "model": "anthropic.claude-instant-v1", + "usage": { + "prompt_tokens": null, + "completion_tokens": null, + "total_tokens": null + } +} +``` + +## Boto3 - Authentication + ### Passing credentials as parameters - Completion() Pass AWS credentials as parameters to litellm.completion ```python @@ -105,44 +147,3 @@ Here's an example of using a bedrock model with LiteLLM | AI21 J2-Ultra | `completion(model='ai21.j2-ultra-v1', messages=messages)` | `os.environ['AWS_ACCESS_KEY_ID']`, `os.environ['AWS_SECRET_ACCESS_KEY']`, `os.environ['AWS_REGION_NAME']` | -## Streaming - -```python -import os -from litellm import completion - -os.environ["AWS_ACCESS_KEY_ID"] = "" -os.environ["AWS_SECRET_ACCESS_KEY"] = "" -os.environ["AWS_REGION_NAME"] = "" - -response = completion( - model="bedrock/anthropic.claude-instant-v1", - messages=[{ "content": "Hello, how are you?","role": "user"}], - stream=True -) - -for chunk in response: - print(chunk) -``` - -### Example Streaming Output Chunk -```json -{ - "choices": [ - { - "finish_reason": null, - "index": 0, - "delta": { - "content": "ase can appeal the case to a higher federal court. If a higher federal court rules in a way that conflicts with a ruling from a lower federal court or conflicts with a ruling from a higher state court, the parties involved in the case can appeal the case to the Supreme Court. In order to appeal a case to the Sup" - } - } - ], - "created": null, - "model": "amazon.titan-tg1-large", - "usage": { - "prompt_tokens": null, - "completion_tokens": null, - "total_tokens": null - } -} -```