Skip to content
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

7 detail backend for qa on html #29

Merged
merged 4 commits into from
Oct 4, 2023
Merged

Conversation

mt7180
Copy link
Owner

@mt7180 mt7180 commented Oct 1, 2023

introduced new class AIHtmlDocument which inherits from AITextDocument, while the _load_document method is overwritten to load a html file via url. On the backend the upload route is extended to receive an Uploadfile or a str (url).
The test implementation is postponed to a new issue #28

from my perspective ready to merge

@mt7180 mt7180 requested a review from Zaubeerer October 1, 2023 18:25
@mt7180 mt7180 linked an issue Oct 1, 2023 that may be closed by this pull request
3 tasks
@mt7180
Copy link
Owner Author

mt7180 commented Oct 2, 2023

I totally messed up here, since I didn't recognize, that the url upload works, but the file upload not anymore. Currently working on a fix, but until now wasn't able to resolve the 422 Unprocessible Entity. I Found out that it is not possible to combine Uploadfile and string url in one Basemodel and also as separate route function parameters it does not work, yet ... working on this ...

@mt7180
Copy link
Owner Author

mt7180 commented Oct 2, 2023

OK, fixed it, ready to merge.

@mt7180
Copy link
Owner Author

mt7180 commented Oct 3, 2023

@Zaubeerer I am ready to merge from my perspective and waiting for your review/ approve.

@Zaubeerer
Copy link
Collaborator

Awesome that you found the bug and fixed it :)

Do we already have a follow-up issue to create tests?

Whenever you find such a bug, it is important to create a test that would have caught the bug.

Copy link
Collaborator

@Zaubeerer Zaubeerer left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Only some minor feedback :)

@@ -0,0 +1,17 @@
repos:
Copy link
Collaborator

Choose a reason for hiding this comment

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

this file should be deleted (pre commit config needs to be at root of project directory)

Copy link
Owner Author

Choose a reason for hiding this comment

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

yes, I don't know how it went to the backend directory but I put it to root now(again).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like you did not push the changes yet?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Now I pushed everything ...

Comment on lines 88 to 92
except Exception as e:
return TextSummaryModel(
file_name=file.filename,
file_name="",
text_category="",
summary=f"There was an error on uploading the file: {e.args}",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you really want the error to pass semi-silently?

This may introduce some errors downstream, unless you do something with the exceptions that are logged via the return message 🤔

Copy link
Owner Author

Choose a reason for hiding this comment

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

See comment below, I detailed the Exception handling and removed the silencing of Exceptions in general.

Comment on lines 128 to 129
except Exception as e:
return TextResponseModel(message=f"Error: {e.args}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not good practice and will likely be complained about by code quality checks.

Are there some specific exceptions that you want to accept?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I removed the whole try - except handling here, since it is not really needed ...

@Zaubeerer
Copy link
Collaborator

Let me know, when the conflicts are resolved :)

Comment on lines +89 to 102
except HTTPException as e:
message = (f"There was an error on uploading your text/ url: {e.args}",)
except MissingSchema as e:
message = f"There was a problem with the provided url: {e.args}"
except OSError as e:
message = f"""There was an unexpected OSError on saving the file:
{e.args}, please ask the admin for write permissions
"""
return TextSummaryModel(
file_name=file_name,
text_category=document.text_category,
summary=document.text_summary,
text_category=text_category,
summary=message,
used_tokens=token_counter.total_llm_token_count,
)
Copy link
Owner Author

Choose a reason for hiding this comment

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

@Zaubeerer : I detailed the Exception block and removed the silencing of Exceptions in general. Nevertheless, the error message was and is printed in the chat on the frontend, so it never really went through silently.

Copy link
Owner Author

Choose a reason for hiding this comment

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

@Zaubeerer : The conflicts are resolved and I implemented your suggested adjustments. Thank you :) !

@mt7180 mt7180 merged commit c50e323 into main Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detail backend for qa on html
2 participants