Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Injectable } from '@nestjs/common';
import { BedrockRuntimeClient, ConverseCommand } from '@aws-sdk/client-bedrock-runtime';
import { Injectable } from '@nestjs/common';
import { IAIProvider } from './ai-provider.interface.js';

@Injectable()
export class AmazonBedrockAiProvider implements IAIProvider {
private readonly bedrockRuntimeClient: BedrockRuntimeClient;
private readonly modelId: string = 'global.anthropic.claude-sonnet-4-5-20250929-v1:0';
private readonly maxTokens: number = 1024;

constructor() {
this.bedrockRuntimeClient = new BedrockRuntimeClient();
Expand All @@ -22,7 +21,6 @@ export class AmazonBedrockAiProvider implements IAIProvider {
const command = new ConverseCommand({
modelId: this.modelId,
messages: conversation,
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the maxTokens configuration from inferenceConfig means the model will use its default token limit. This could lead to unexpectedly long responses or increased costs. If this change is intentional, consider documenting why the limit was removed. If not, the maxTokens parameter should be restored to control response length and costs.

Suggested change
messages: conversation,
messages: conversation,
inferenceConfig: {
maxTokens: 1024, // Limit response length to control cost and latency
},

Copilot uses AI. Check for mistakes.
inferenceConfig: { maxTokens: this.maxTokens },
});
try {
const response = await this.bedrockRuntimeClient.send(command);
Expand Down
34 changes: 17 additions & 17 deletions backend/src/interceptors/timeout.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import { Messages } from '../exceptions/text/messages.js';

@Injectable()
export class TimeoutInterceptor implements NestInterceptor {
intercept(_context: ExecutionContext, next: CallHandler): Observable<any> {
const timeoutMs = process.env.NODE_ENV !== 'test' ? 15000 : 200000;
return next.handle().pipe(
timeout(timeoutMs),
catchError((err) => {
if (err instanceof TimeoutError) {
return throwError(
() =>
new RequestTimeoutException({
message: Messages.CONNECTION_TIMED_OUT,
}),
);
}
return throwError(() => err);
}),
);
}
intercept(_context: ExecutionContext, next: CallHandler): Observable<any> {
const timeoutMs = process.env.NODE_ENV !== 'test' ? 15000 : 200000;
return next.handle().pipe(
timeout(timeoutMs),
catchError((err) => {
if (err instanceof TimeoutError) {
return throwError(
() =>
new RequestTimeoutException({
message: Messages.CONNECTION_TIMED_OUT,
}),
);
}
return throwError(() => err);
}),
);
}
}
Loading
Loading