Skip to content

Commit cc191f6

Browse files
authored
Merge pull request #57 from ModusCreateOrg/ADE-152
[ADE-152] Refactor BedrockService to streamline credential handling
2 parents 2ba4f29 + b93574a commit cc191f6

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

frontend/src/common/services/ai/bedrock.service.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,27 @@ class BedrockService {
100100
throw new Error('No credentials available');
101101
}
102102

103+
const bedrockCredentials: {
104+
accessKeyId: string;
105+
secretAccessKey: string;
106+
expiration?: Date;
107+
sessionToken?: string;
108+
} = {
109+
accessKeyId: credentials.accessKeyId,
110+
secretAccessKey: credentials.secretAccessKey,
111+
};
112+
113+
if (credentials.expiration) {
114+
bedrockCredentials.expiration = credentials.expiration;
115+
}
116+
117+
if (credentials.sessionToken) {
118+
bedrockCredentials.sessionToken = credentials.sessionToken;
119+
}
120+
103121
this.client = new BedrockRuntimeClient({
104122
region: REGION,
105-
credentials: {
106-
accessKeyId: credentials.accessKeyId,
107-
secretAccessKey: credentials.secretAccessKey,
108-
sessionToken: credentials.sessionToken,
109-
expiration: credentials.expiration
110-
}
123+
credentials: bedrockCredentials
111124
});
112125
} catch (error) {
113126
console.error('Error initializing Bedrock client:', error);

0 commit comments

Comments
 (0)