Fantasy-Fit / fantasy-fit-web

Creative Commons Zero v1.0 Universal
3 stars 2 forks source link

build chatbot post api #139

Open chris-t-li opened 1 year ago

chris-t-li commented 1 year ago
  1. Create chatbotApiSlice to that will send a post request to "http://localhost:8000/fitbot/botcomment" where body of the request will be a prompt history which is an array of objects in the following format:
{
    "prompts": [
        {"role": "user", "content": "On 05-May-2023 user1 posted a workout! Run for 20 mins, earning 320 points!"},
        {"role": "user", "content": "On 05-May-2023 user2 posted a workout! Cycle for 45 mins, earning 472 points!"},
        {"role": "user", "content": "On 08-May-2023 user3 posted a workout! Cycle for 133 mins, earning 1396 points!"},
        {"role": "user", "content": "On 11-May-2023 user4 posted a workout! Open Water Swimming for 180 mins, earning 1170 points!"},
        {"role": "user", "content": "On 16-May-2023 user5 posted a workout! Soccer for 90 mins, earning 1260 points!"}
    ]
}
  1. In the Posts component, define the workoutContextArray that will be the array of prompts that is sent to the above endpoint.

  2. In Posts#Controller, add functionality if the params[:post_type] is "bot", the user that is creating the post shall be the bot in the competition

  3. For testing and initial implementation, a "ChatBot" button has been created in Posts with an onClick event that sends a post request to the fantasy_bot_ai api endpoint "/fitbot/comment", which sends a request to openai with the array of prompts, and receives a GPT reply that is sent to the client. The client then renders the response by creating a post/comment generated by the bot participant in the competition

****NOTE This is currently in testing mode only. Functionality will not work in deployment as fantasy_bot_ai has not yet been deployed. To test this functionality, open https://github.com/Fantasy-Fit/fantasyfit_bot_ai as per instructions in the README END****

netlify[bot] commented 1 year ago

Deploy Preview for fantasyfit ready!

Name Link
Latest commit f5cb835715c0efa98a149a1cfe81ffe7420b5924
Latest deploy log https://app.netlify.com/sites/fantasyfit/deploys/646f74069f737e0007ca252e
Deploy Preview https://deploy-preview-139--fantasyfit.netlify.app/
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.