-
Notifications
You must be signed in to change notification settings - Fork 115
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
[FIX]: Handle Error response from AI API #548
Conversation
let status = 'success'; | ||
let message = ''; | ||
|
||
for (const value of Object.values(responses)) { |
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.
const errorResponse = Object.values(responses))
.find(res => res.status==='error')
const {status = 'success', message = ''} = errorResponse ?? {}
// if `errorResponse` is not found, default it to an empty object
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.
we rarely use for
and while
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.
in fact use an if statement
if(errorResponse)
return {status: errorResponse.status, message: errorResponse.message}
return {status:"success", message:""}
}); | ||
|
||
function checkForErrors(responses: any): { status: string; message: string } { |
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.
usually we use
const func = () => {}
@samad-yar-khan will submit the final review |
|
||
def _fetch_completion( | ||
self, messages: List[Dict[str, str]] | ||
) -> Union[Dict[str, str], Dict[str, Union[str, int]]]: |
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.
this seems over complicated
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.
i'll try to simplify it
|
||
def get_dora_metrics_score( | ||
self, four_keys_data: Dict[str, float] | ||
) -> Dict[str, str]: | ||
) -> Union[Dict[str, str], Dict[str, Union[str, int]]]: |
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.
although this serves our usecase, this return type feels like an overkill
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.
and super hard to decipher
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.
I will make it simpler TBH I don't like this either
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.
LGTM, but I think a lot of this can be made better by better exception handling, lets take those up in future PRs: https://flask.palletsprojects.com/en/2.3.x/errorhandling/
@VipinDevelops merge this then! |
Linked Issue(s)
#546
Acceptance Criteria fulfillment
Proposed changes (including videos or screenshots)
Screencast.from.2024-09-15.11-54-08.webm