Skip to content

Commit b65e17f

Browse files
committed
feature(docs): Documented the aws_provider class. Renamed the aws md files. Updated docs in aws_providers.py
1 parent 1b45f72 commit b65e17f

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed
File renamed without changes.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
sidebar_position: 9
3+
---
4+
5+
# dspy.Bedrock, dspy.Sagemaker
6+
7+
### Usage
8+
9+
The `AWSProvider` class is the base class for the AWS providers - `dspy.Bedrock` and `dspy.Sagemaker`. An instance of one of these providers is passed to the constructor when creating an instance of an AWS model class (e.g., `dspy.AWSMistral`) that is ultimately used to query the model.
10+
11+
```python
12+
# Notes:
13+
# 1. Install boto3 to use AWS models.
14+
# 2. Configure your AWS credentials with the AWS CLI before using these models
15+
16+
# initialize the bedrock aws provider
17+
bedrock = dspy.Bedrock(region_name="us-west-2")
18+
19+
# initialize the sagemaker aws provider
20+
sagemaker = dspy.Sagemaker(region_name="us-west-2")
21+
```
22+
23+
### Constructor
24+
25+
The `Bedrock` constructor initializes the base class `AWSProvider`.
26+
27+
```python
28+
class Bedrock(AWSProvider):
29+
"""This class adds support for Bedrock models."""
30+
31+
def __init__(
32+
self,
33+
region_name: str,
34+
profile_name: Optional[str] = None,
35+
batch_n_enabled: bool = False, # This has to be setup manually on Bedrock.
36+
) -> None:
37+
```
38+
39+
**Parameters:**
40+
- `region_name` (str): The AWS region where this LM is hosted.
41+
- `profile_name` (str, optional): boto3 credentials profile.
42+
- `batch_n_enabled` (bool): If False, call the LM N times rather than batching.
43+
44+
### Methods
45+
46+
```python
47+
def call_model(self, model_id: str, body: str) -> str:
48+
```
49+
This function implements the actual invocation of the model on AWS using the boto3 provider.
50+
51+
<br/>
52+
53+
`Sagemaker` works exactly the same as `Bedrock`.

dsp/modules/aws_providers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(
8989
"""_summary_.
9090
9191
Args:
92-
region_name (str, optional): The AWS region where this LM is hosted.
92+
region_name (str): The AWS region where this LM is hosted.
9393
profile_name (str, optional): boto3 credentials profile.
9494
"""
9595
super().__init__(region_name, "bedrock-runtime", profile_name, batch_n_enabled)

0 commit comments

Comments
 (0)