Eduhub-Community / Eduhub-Community.github.io

Community Website
https://eduhubcommunity.tech/
MIT License
80 stars 190 forks source link

Incomplete Error Handling in chatbot #549

Open 0rigin-c0de opened 1 year ago

0rigin-c0de commented 1 year ago

Describe the bug

API URL: The API URL was specified inside the generateResponse function, but it should be defined globally, just like the API key, to maintain consistency.

Scroll Behavior: The code was missing proper scrolling behavior to ensure the chatbox scrolls to the bottom after sending messages or opening/closing the chatbot. This makes the conversation flow smoother and keeps the latest messages visible.

Error Handling: If there was an error with the API request, it was not handled gracefully. The code needed proper error handling to display a user-friendly error message in the chat.

Code Structure: The code could benefit from a bit of refactoring to improve readability and maintainability.

Expected behaviour

Scrolling: After sending a message, the chatbox should scroll to the bottom to ensure that the latest messages are visible to the user. Additionally, when opening or closing the chatbot, the chatbox should also scroll to the bottom.

Error Handling: If there's an error while making the API request (e.g., API key issue or network error), the chatbot should display an error message in the chat with an "error" style. This error message should indicate that the user should try again.

Screenshots

No response

Additional context

No response

Code of Conduct

github-actions[bot] commented 1 year ago

👋 @0rigin-c0de

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.

Please make sure you have given us as much context as possible.