Omnis utilizes Tanstack query JS library to send API requests. This offers functionalities such as loading state, error handlers etc.
Whenever the user sends a prompt, it undergoes the following flow:
- User enters their prompt.
- The prompt is saved in the State and the Local storage as a Message object with necessary details.
- The prompt is then sent to the API endpoint via Tanstack query.
- While the API request is processing, The loading state is utilised to show the user that the request is processing.
- If the request ends in success. The response(usually in markdown) is parsed and displayed to the user. The response is also saved in the State and the Local Storage.
- If the request ends in error. The error message is displayed to the user in a toast message