Skip to content

Commit

Permalink
Merge pull request #1755 from benjidotsh/ai/bedrock-max-retries-config
Browse files Browse the repository at this point in the history
feat(ai): make AWS Bedrock maxRetries configurable
  • Loading branch information
Xantier authored Dec 11, 2024
2 parents 5417267 + 4e08917 commit 2344125
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-insects-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roadiehq/rag-ai-backend-embeddings-aws': minor
---

Made `maxRetries` configurable
6 changes: 4 additions & 2 deletions plugins/backend/rag-ai-backend-embeddings-aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ The module expects 2 pieces of configuration:

### AWS Bedrock configuration

The module expects the name of the embeddings generative AI model to be configured via app-config.
The module expects the name of the embeddings generative AI model to be configured via app-config. Optionally, you can also provide the maximum number of retries for the AWS SDK client.

```yaml
ai:
embeddings:
awsBedrock:
bedrock:
# Name of the Bedrock model to use to create Embeddings
modelName: 'amazon.titan-embed-text-v1'
# Maximum number of retries for the AWS SDK client
maxRetries: 3
```
### AWS Credentials Configuration
Expand Down
6 changes: 5 additions & 1 deletion plugins/backend/rag-ai-backend-embeddings-aws/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ export interface Config {
*/
ai: {
embeddings: {
awsBedrock: {
bedrock: {
/**
* Name of the Bedrock model to use to create Embeddings
*/
modelName: string;
/**
* Maximum number of retries for the AWS SDK client. Defaults to 3
*/
maxRetries?: string;
};
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { BedrockCohereEmbeddings } from './BedrockCohereEmbeddings';

export type BedrockConfig = {
modelName: string;
maxRetries?: number;
};

export class RoadieBedrockAugmenter extends DefaultVectorAugmentationIndexer {
Expand All @@ -41,8 +42,14 @@ export class RoadieBedrockAugmenter extends DefaultVectorAugmentationIndexer {
model: config.bedrockConfig.modelName,
};
const embeddings = config.bedrockConfig.modelName.includes('cohere')
? new BedrockCohereEmbeddings({ ...embeddingsConfig, maxRetries: 3 })
: new BedrockEmbeddings({ ...embeddingsConfig, maxRetries: 3 });
? new BedrockCohereEmbeddings({
...embeddingsConfig,
maxRetries: config.bedrockConfig.maxRetries ?? 3,
})
: new BedrockEmbeddings({
...embeddingsConfig,
maxRetries: config.bedrockConfig.maxRetries ?? 3,
});

super({ ...config, embeddings });
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/backend/rag-ai-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ai:
concurrencyLimit: 10

# AWS Bedrock Embeddings configuration
awsBedrock:
bedrock:
# (Required) Name of the Bedrock model to use to create Embeddings.
modelName: 'amazon.titan-embed-text-v1'

Expand Down

0 comments on commit 2344125

Please sign in to comment.