Avoiding delay for HTTP in HTTP requests. #2658
-
Hello, I am trying to automate the request for comments process by using ChatGPT. For example, when a user requests a comment for their exercise, an HTTP request is made to ChatGPT with the user's question, test results, etc. Then, a comment is automatically created on the back-end with a response from ChatGPT. The user can then see this comment on the Request for Comments page, where they will see the response from ChatGPT as a comment. My concern is that the request to ChatGPT takes time, as it is an HTTP request and sometimes can take up to 30 seconds. I don't want the user to wait during the comment requesting process. I would like some ideas on how I can implement this better or make the process faster. Any other ideas or solutions on this topic are also welcome. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @seemantTUI, this sounds like a pretty good use case for a background job. In Rails, you may use ActiveJob for this purpose -- here is a guide to get started. ActiveJob can be configured with different job backends. In CodeOcean (and CodeHarbor) that's SolidQueue (see here). If you configured CodeOcean according to the local setup guide, you should be good and can start using ActiveJob (without worrying about the backend). We don't have a developer-defined job in CodeOcean yet (only those created by other libraries), but if you want to get a peak look, I would recommend taking a look at ActiveJobs in CodeHarbor. In case something goes wrong, you can also reschedule a job (e.g., because of network issues). I hope this helps; good luck with getting started using ActiveJob. Best, |
Beta Was this translation helpful? Give feedback.
Hi @seemantTUI,
this sounds like a pretty good use case for a background job. In Rails, you may use ActiveJob for this purpose -- here is a guide to get started. ActiveJob can be configured with different job backends. In CodeOcean (and CodeHarbor) that's SolidQueue (see here). If you configured CodeOcean according to the local setup guide, you should be good and can start using ActiveJob (without worrying about the backend). We don't have a developer-defined job in CodeOcean yet (only those created by other libraries), but if you want to get a peak look, I would recommend taking a look at ActiveJobs in CodeHarbor. In case something goes wrong, you can also reschedule a job (e.g., because…