-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Bedrock API: Add option to configure API endpoint (#1018) #1063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; | ||
import software.amazon.awssdk.regions.Region; | ||
|
||
import java.net.URI; | ||
import java.time.Duration; | ||
import java.util.List; | ||
|
||
|
@@ -113,6 +114,21 @@ public Anthropic3ChatBedrockApi(String modelId, AwsCredentialsProvider credentia | |
super(modelId, credentialsProvider, region, objectMapper, timeout); | ||
} | ||
|
||
/** | ||
* Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
* | ||
* @param modelId The model id to use. See the {@link AnthropicChatModel} for the supported models. | ||
* @param credentialsProvider The credentials provider to connect to AWS. | ||
* @param region The AWS region to use. | ||
* @param objectMapper The object mapper to use for JSON serialization and deserialization. | ||
* @param timeout The timeout to use. | ||
* @param endpointOverride The endpoint to use. | ||
*/ | ||
public Anthropic3ChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region, | ||
ObjectMapper objectMapper, Duration timeout, URI endpointOverride) { | ||
super(modelId, credentialsProvider, region, objectMapper, timeout, endpointOverride); | ||
} | ||
|
||
// https://github.com/build-on-aws/amazon-bedrock-java-examples/blob/main/example_code/bedrock-runtime/src/main/java/aws/community/examples/InvokeBedrockStreamingAsync.java | ||
|
||
// https://docs.anthropic.com/claude/reference/complete_post | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
// @formatter:off | ||
package org.springframework.ai.bedrock.cohere.api; | ||
|
||
import java.net.URI; | ||
import java.time.Duration; | ||
import java.util.List; | ||
|
||
|
@@ -108,6 +109,21 @@ public CohereChatBedrockApi(String modelId, AwsCredentialsProvider credentialsPr | |
super(modelId, credentialsProvider, region, objectMapper, timeout); | ||
} | ||
|
||
/** | ||
* Create a new CohereChatBedrockApi instance using the provided credentials provider, region and object mapper. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
* | ||
* @param modelId The model id to use. See the {@link CohereChatModel} for the supported models. | ||
* @param credentialsProvider The credentials provider to connect to AWS. | ||
* @param region The AWS region to use. | ||
* @param objectMapper The object mapper to use for JSON serialization and deserialization. | ||
* @param timeout The timeout to use. | ||
* @param endpointOverride The endpoint to use. | ||
*/ | ||
public CohereChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region, | ||
ObjectMapper objectMapper, Duration timeout, URI endpointOverride) { | ||
super(modelId, credentialsProvider, region, objectMapper, timeout, endpointOverride); | ||
} | ||
|
||
/** | ||
* CohereChatRequest encapsulates the request parameters for the Cohere command model. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
// @formatter:off | ||
package org.springframework.ai.bedrock.cohere.api; | ||
|
||
import java.net.URI; | ||
import java.time.Duration; | ||
import java.util.List; | ||
|
||
|
@@ -109,6 +110,22 @@ public CohereEmbeddingBedrockApi(String modelId, AwsCredentialsProvider credenti | |
super(modelId, credentialsProvider, region, objectMapper, timeout); | ||
} | ||
|
||
/** | ||
* Create a new CohereEmbeddingBedrockApi instance using the provided credentials provider, region and object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
* mapper. | ||
* | ||
* @param modelId The model id to use. See the {@link CohereEmbeddingModel} for the supported models. | ||
* @param credentialsProvider The credentials provider to connect to AWS. | ||
* @param region The AWS region to use. | ||
* @param objectMapper The object mapper to use for JSON serialization and deserialization. | ||
* @param timeout The timeout to use. | ||
* @param endpointOverride The endpoint to use. | ||
*/ | ||
public CohereEmbeddingBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region, | ||
ObjectMapper objectMapper, Duration timeout, URI endpointOverride) { | ||
super(modelId, credentialsProvider, region, objectMapper, timeout, endpointOverride); | ||
} | ||
|
||
/** | ||
* The Cohere Embed model request. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
// @formatter:off | ||
package org.springframework.ai.bedrock.jurassic2.api; | ||
|
||
import java.net.URI; | ||
import java.time.Duration; | ||
import java.util.List; | ||
|
||
|
@@ -109,6 +110,21 @@ public Ai21Jurassic2ChatBedrockApi(String modelId, AwsCredentialsProvider creden | |
super(modelId, credentialsProvider, region, objectMapper, timeout); | ||
} | ||
|
||
/** | ||
* Create a new Ai21Jurassic2ChatBedrockApi instance. | ||
* | ||
* @param modelId The model id to use. See the {@link Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatModel} for the supported models. | ||
* @param credentialsProvider The credentials provider to connect to AWS. | ||
* @param region The AWS region to use. | ||
* @param objectMapper The object mapper to use for JSON serialization and deserialization. | ||
* @param timeout The timeout to use. | ||
* @param endpointOverride The endpoint to use. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "The endpoint override to use." |
||
*/ | ||
public Ai21Jurassic2ChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region, | ||
ObjectMapper objectMapper, Duration timeout, URI endpointOverride) { | ||
super(modelId, credentialsProvider, region, objectMapper, timeout, endpointOverride); | ||
} | ||
|
||
/** | ||
* AI21 Jurassic2 chat request parameters. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
import org.springframework.ai.bedrock.llama.api.LlamaChatBedrockApi.LlamaChatResponse; | ||
import org.springframework.ai.model.ChatModelDescription; | ||
|
||
import java.net.URI; | ||
import java.time.Duration; | ||
|
||
// @formatter:off | ||
|
@@ -106,6 +107,21 @@ public LlamaChatBedrockApi(String modelId, AwsCredentialsProvider credentialsPro | |
super(modelId, credentialsProvider, region, objectMapper, timeout); | ||
} | ||
|
||
/** | ||
* Create a new LlamaChatBedrockApi instance using the provided credentials provider, region and object mapper. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same small changes here and also all places similarly set below. |
||
* | ||
* @param modelId The model id to use. See the {@link LlamaChatModel} for the supported models. | ||
* @param credentialsProvider The credentials provider to connect to AWS. | ||
* @param region The AWS region to use. | ||
* @param objectMapper The object mapper to use for JSON serialization and deserialization. | ||
* @param timeout The timeout to use. | ||
* @param endpointOverride The endpoint to use. | ||
*/ | ||
public LlamaChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region, | ||
ObjectMapper objectMapper, Duration timeout, URI endpointOverride) { | ||
super(modelId, credentialsProvider, region, objectMapper, timeout, endpointOverride); | ||
} | ||
|
||
/** | ||
* LlamaChatRequest encapsulates the request parameters for the Meta Llama chat model. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can also specify here that we require a new parameter, the endpoint override.