You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The constructor initializes the base class `LM` and the `AWSModel` class.
33
+
The `AWSMistral`constructor initializes the base class `AWSModel` which itself inherits from the `LM` class.
34
34
35
35
```python
36
36
classAWSMistral(AWSModel):
@@ -47,15 +47,40 @@ class AWSMistral(AWSModel):
47
47
```
48
48
49
49
**Parameters:**
50
-
-`aws_provider` (AWSProvider): The aws provider to use. One of `Bedrock` or `Sagemaker`.
51
-
-`model` (_str_): Mistral AI pretrained models. Defaults to `mistral-medium-latest`.
50
+
-`aws_provider` (AWSProvider): The aws provider to use. One of `dspy.Bedrock` or `dspy.Sagemaker`.
51
+
-`model` (_str_): Mistral AI pretrained models. For Bedrock, this is the Model ID in https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html#model-ids-arns. For Sagemaker, this is the endpoint name.
52
52
-`max_context_size` (_Optional[int]_, _optional_): Max context size for this model. Defaults to 32768.
53
53
-`max_new_tokens` (_Optional[int]_, _optional_): Max new tokens possible for this model. Defaults to 1500.
54
54
-`**kwargs`: Additional language model arguments to pass to the API provider.
55
55
56
56
### Methods
57
57
58
-
Refer to [`dspy.OpenAI`](https://dspy-docs.vercel.app/api/language_model_clients/OpenAI) documentation.
58
+
```python
59
+
def_format_prompt(self, raw_prompt: str) -> str:
60
+
```
61
+
This function formats the prompt for the model. Refer to the model card for the specific formatting required.
This function creates the body of the request to the model. It takes the prompt and any additional keyword arguments and returns a tuple of the number of tokens to generate and a dictionary of keys including the prompt used to create the body of the request.
69
+
70
+
<br/>
71
+
72
+
```python
73
+
def_call_model(self, body: str) -> str:
74
+
```
75
+
This function calls the model using the provider `call_model()` function and extracts the generated text (completion) from the provider-specific response.
76
+
77
+
<br/>
78
+
79
+
The above model-specific methods are called by the `AWSModel::basic_request()` method, which is the main method for querying the model. This method takes the prompt and any additional keyword arguments and calls the `AWSModel::_simple_api_call()` which then delegates to the model-specific `_create_body()` and `_call_model()` methods to create the body of the request, call the model and extract the generated text.
80
+
81
+
82
+
Refer to [`dspy.OpenAI`](https://dspy-docs.vercel.app/api/language_model_clients/OpenAI) documentation for information on the `LM` base class functionality.
59
83
84
+
<br/>
60
85
61
86
`AWSAnthropic` and `AWSMeta` work exactly the same as `AWSMistral`.
0 commit comments