-
Notifications
You must be signed in to change notification settings - Fork 8
feat(PM-1794): Update workflow implementation #38
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
481a8a1
feat: update workflow implementation
hentrymartin e8df271
fix: lint
hentrymartin 8786353
fix: use NotFoundException instead of Error
hentrymartin b52d2e7
fix: deploy to dev
hentrymartin f022f89
fix: lint
hentrymartin 6a2d8e4
fix: conflicts
hentrymartin 53a3054
fix: review comments
hentrymartin b823090
fix: review comments
hentrymartin 4e76f6c
updated from develop
hentrymartin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { Injectable, BadRequestException } from '@nestjs/common'; | ||
import { Injectable, BadRequestException, Logger } from '@nestjs/common'; | ||
import { PrismaService } from '../../shared/modules/global/prisma.service'; | ||
import { CreateAiWorkflowDto } from '../../dto/aiWorkflow.dto'; | ||
import { CreateAiWorkflowDto, UpdateAiWorkflowDto } from '../../dto/aiWorkflow.dto'; | ||
import { ScorecardStatus } from 'src/dto/scorecard.dto'; | ||
|
||
@Injectable() | ||
export class AiWorkflowService { | ||
private readonly logger: Logger = new Logger(AiWorkflowService.name); | ||
constructor(private readonly prisma: PrismaService) {} | ||
|
||
async scorecardExists(scorecardId: string): Promise<boolean> { | ||
|
@@ -27,13 +28,15 @@ export class AiWorkflowService { | |
|
||
const scorecardExists = await this.scorecardExists(scorecardId); | ||
if (!scorecardExists) { | ||
this.logger.error(`Active scorecard with id ${scorecardId} does not exist.`); | ||
throw new BadRequestException( | ||
`Active scorecard with id ${scorecardId} does not exist.`, | ||
); | ||
} | ||
|
||
const llmExists = await this.llmModelExists(llmId); | ||
if (!llmExists) { | ||
this.logger.error(`LLM model with id ${llmId} does not exist.`); | ||
throw new BadRequestException( | ||
`LLM model with id ${llmId} does not exist.`, | ||
); | ||
|
@@ -57,8 +60,52 @@ export class AiWorkflowService { | |
where: { id }, | ||
}); | ||
if (!workflow) { | ||
this.logger.error(`AI workflow with id ${id} not found.`); | ||
throw new Error(`AI workflow with id ${id} not found.`); | ||
} | ||
return workflow; | ||
} | ||
|
||
async updateWorkflow( | ||
id: string, | ||
updateDto: UpdateAiWorkflowDto, | ||
updatedBy?: string, | ||
) { | ||
const existingWorkflow = await this.prisma.aiWorkflow.findUnique({ | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
where: { id }, | ||
}); | ||
if (!existingWorkflow) { | ||
this.logger.error(`AI workflow with id ${id} not found.`); | ||
throw new Error(`AI workflow with id ${id} not found.`); | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
if (updateDto.scorecardId) { | ||
const scorecardExists = await this.scorecardExists(updateDto.scorecardId); | ||
if (!scorecardExists) { | ||
this.logger.error(`Active scorecard with id ${updateDto.scorecardId} does not exist.`); | ||
throw new BadRequestException( | ||
`Active scorecard with id ${updateDto.scorecardId} does not exist.`, | ||
); | ||
} | ||
} | ||
|
||
if (updateDto.llmId) { | ||
const llmExists = await this.llmModelExists(updateDto.llmId); | ||
if (!llmExists) { | ||
this.logger.error(`LLM model with id ${updateDto.llmId} does not exist.`); | ||
throw new BadRequestException( | ||
`LLM model with id ${updateDto.llmId} does not exist.`, | ||
); | ||
} | ||
} | ||
|
||
return this.prisma.aiWorkflow.update({ | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
where: { id }, | ||
data: { | ||
...updateDto, | ||
updatedBy, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is either user handle making the call or |
||
updatedAt: new Date(), | ||
}, | ||
}); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.