Skip to content

Commit

Permalink
Adjust to new bedrock page
Browse files Browse the repository at this point in the history
  • Loading branch information
J2-D2-3PO committed Jan 22, 2025
1 parent 90ad021 commit 6c16cf6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
18 changes: 10 additions & 8 deletions docs/docs/guides/integrations/bedrock.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Amazon Bedrock

Weave automatically tracks and logs LLM calls made via Amazon Bedrock, AWS's fully managed service that offers foundation models from leading AI companies through a unified API.
Weave automatically tracks and logs LLM calls made via [Amazon Bedrock](https://aws.amazon.com/bedrock/), a fully managed service that offers foundation models from leading AI companies through a unified API.

## Traces
:::note
For a full-length tutorial demonstrating both basic and advanced usage of Weave with Amazon Bedrock, try [Working with Amazon Bedrock](/reference/gen_notebooks/bedrock)
:::

Weave will automatically capture traces for Bedrock API calls. You can use the Bedrock client as usual after initializing Weave and patching the client:
## Log traces

Weave automatically captures traces for Bedrock API calls. You can use the Bedrock client as usual after initializing Weave and patching the client:

```python
import weave
Expand Down Expand Up @@ -35,7 +39,7 @@ response_dict = json.loads(response.get('body').read())
print(response_dict["content"][0]["text"])
```

of using the `converse` API:
The following example shows how to use the `converse` API:

```python
messages = [{"role": "user", "content": [{"text": "What is the capital of France?"}]}]
Expand All @@ -50,7 +54,7 @@ print(response["output"]["message"]["content"][0]["text"])

```

## Wrapping with your own ops
## Wrap Bedrock calls with Weave Ops

You can create reusable operations using the `@weave.op()` decorator. Here's an example showing both the `invoke_model` and `converse` APIs:

Expand Down Expand Up @@ -99,7 +103,7 @@ def call_model_converse(

## Create a `Model` for easier experimentation

You can create a Weave Model to better organize your experiments and capture parameters. Here's an example using the `converse` API:
You can create a Weave [Model](../core-types/models.md) to better organize your experiments and capture parameters. Here's an example using the `converse` API:

```python
class BedrockLLM(weave.Model):
Expand Down Expand Up @@ -133,5 +137,3 @@ model = BedrockLLM(
result = model.predict("What is the best way to handle errors in Python?")
print(result)
```

This approach allows you to version your experiments and easily track different configurations of your Bedrock-based application.
File renamed without changes.
10 changes: 0 additions & 10 deletions docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,6 @@ const sidebars: SidebarsConfig = {
},
],
},
{
label: "🍳 Tutorials",
...CATEGORY_SECTION_HEADER_MIXIN,
type: "category",
collapsible: true,
collapsed: true,
items: [
"guides/cookbooks/bedrock",
],
},
{
label: "🔥 Integrations",
...CATEGORY_SECTION_HEADER_MIXIN,
Expand Down

0 comments on commit 6c16cf6

Please sign in to comment.