Skip to content
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

feat(ai): make AWS Bedrock maxRetries configurable #1755

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading