-
-
Notifications
You must be signed in to change notification settings - Fork 18
refactor: enhance logging and code formatting in SharedJobsService #1487
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
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 | ||
|---|---|---|---|---|
|
|
@@ -4,38 +4,40 @@ 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 temperature: number = 0.7; | ||||
| private readonly maxTokens: number = 1024; | ||||
| private readonly region: string = 'us-west-2'; | ||||
| private readonly topP: number = 0.9; | ||||
| private readonly bedrockRuntimeClient: BedrockRuntimeClient; | ||||
| private readonly modelId: string = 'global.anthropic.claude-sonnet-4-5-20250929-v1:0'; | ||||
| private readonly temperature: number = 0.7; | ||||
| private readonly maxTokens: number = 1024; | ||||
| private readonly region: string = 'us-west-2'; | ||||
| private readonly topP: number = 0.9; | ||||
|
|
||||
| constructor() { | ||||
| this.bedrockRuntimeClient = new BedrockRuntimeClient({ | ||||
| region: this.region, | ||||
| }); | ||||
| } | ||||
| public async generateResponse(prompt: string): Promise<string> { | ||||
| const conversation = [ | ||||
| { | ||||
| role: 'user' as const, | ||||
| content: [{ text: prompt }], | ||||
| }, | ||||
| ]; | ||||
| constructor() { | ||||
| this.bedrockRuntimeClient = new BedrockRuntimeClient({ | ||||
| region: this.region, | ||||
| }); | ||||
| } | ||||
| public async generateResponse(prompt: string): Promise<string> { | ||||
| const conversation = [ | ||||
| { | ||||
| role: 'user' as const, | ||||
| content: [{ text: prompt }], | ||||
| }, | ||||
| ]; | ||||
|
|
||||
| const command = new ConverseCommand({ | ||||
| modelId: this.modelId, | ||||
| messages: conversation, | ||||
| inferenceConfig: { maxTokens: this.maxTokens, temperature: this.temperature, topP: this.topP }, | ||||
| }); | ||||
| try { | ||||
| const response = await this.bedrockRuntimeClient.send(command); | ||||
| const responseText = response.output.message?.content[0].text; | ||||
| return responseText || 'No response generated.'; | ||||
| } catch (error) { | ||||
| console.error('Error generating AI response:', error); | ||||
| throw new Error('Failed to generate AI response.'); | ||||
| } | ||||
| } | ||||
| const command = new ConverseCommand({ | ||||
| modelId: this.modelId, | ||||
| messages: conversation, | ||||
| inferenceConfig: { maxTokens: this.maxTokens, temperature: this.temperature, topP: this.topP }, | ||||
| }); | ||||
| try { | ||||
| const response = await this.bedrockRuntimeClient.send(command); | ||||
| console.info('AI response received from Amazon Bedrock.'); | ||||
| const responseText = response.output.message?.content[0].text; | ||||
| console.info('AI response text. ', responseText); | ||||
|
||||
| console.info('AI response text. ', responseText); |
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.
The codebase has a structured logging system using WinstonLogger (see backend/src/entities/logging/winston-logger.ts). While console.info/console.error are used in some places in the codebase, for consistency and better log management (centralized configuration, log levels, transports), consider injecting and using WinstonLogger instead of console.info for this logging statement.