DSPy: The framework for programming—not prompting—language models
Python
feature(docs): Documented the aws_provider class. Renamed the aws md files. Updated docs in aws_providers.py
Dhar Rawalb65e17f02045
diff --git a/docs/api/language_model_clients/aws.md b/docs/api/language_model_clients/aws_models.mdsimilarity index 100%rename from docs/api/language_model_clients/aws.mdrename to docs/api/language_model_clients/aws_models.mddiff --git a/docs/api/language_model_clients/aws_providers.md b/docs/api/language_model_clients/aws_providers.mdnew file mode 100644index 000000000..46950db9e--- /dev/null+++ b/docs/api/language_model_clients/aws_providers.md@@ -0,0 +1,53 @@+---+sidebar_position: 9+---++# dspy.Bedrock, dspy.Sagemaker++### Usage++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.++```python+# Notes:+# 1. Install boto3 to use AWS models.+# 2. Configure your AWS credentials with the AWS CLI before using these models++# initialize the bedrock aws provider+bedrock = dspy.Bedrock(region_name="us-west-2")++# initialize the sagemaker aws provider+sagemaker = dspy.Sagemaker(region_name="us-west-2")+```++### Constructor++The `Bedrock` constructor initializes the base class `AWSProvider`.++```python+class Bedrock(AWSProvider):+ """This class adds support for Bedrock models."""++ def __init__(+ self,+ region_name: str,+ profile_name: Optional[str] = None,+ batch_n_enabled: bool = False, # This has to be setup manually on Bedrock.+ ) -> None:+```++**Parameters:**+- `region_name` (str): The AWS region where this LM is hosted.+- `profile_name` (str, optional): boto3 credentials profile.+- `batch_n_enabled` (bool): If False, call the LM N times rather than batching.++### Methods++```python+def call_model(self, model_id: str, body: str) -> str:+```+This function implements the actual invocation of the model on AWS using the boto3 provider.++<br/>++`Sagemaker` works exactly the same as `Bedrock`.\ No newline at end of filediff --git a/dsp/modules/aws_providers.py b/dsp/modules/aws_providers.pyindex 337ef6cd2..9bf1f936e 100644--- a/dsp/modules/aws_providers.py+++ b/dsp/modules/aws_providers.py@@ -89,7 +89,7 @@ class Bedrock(AWSProvider):"""_summary_.Args:- region_name (str, optional): The AWS region where this LM is hosted.+ region_name (str): The AWS region where this LM is hosted.profile_name (str, optional): boto3 credentials profile."""super().__init__(region_name, "bedrock-runtime", profile_name, batch_n_enabled)