ryanmio / DecodeMe-

DecodeMe! is a coding game with integrated language model.
https://decodeme.app/
MIT License
2 stars 0 forks source link

Implement Custom Instructions Feature for Users #33

Closed ryanmio closed 10 months ago

ryanmio commented 10 months ago

This PR implements a new feature that allows users to set custom instructions for their gameplay. These custom instructions are used to modify the prompts sent to the OpenAI API, providing a more personalized and engaging user experience.

Major Changes

  1. User Document Update: The user document in Firestore is updated to include a customInstructions field. This field stores the custom instructions set by the user.

  2. Assistant Settings Page: The Assistant Settings page (assistantSettings/[userId].js) is updated to include a form for setting custom instructions. The form includes a textarea for each type of custom instruction (e.g., codeGen). The user's current custom instructions are fetched from Firestore and displayed in the form. When the form is submitted, the user's custom instructions in Firestore are updated.

  3. Fetching Custom Instructions: In the home page (index.js), the custom instructions are fetched from Firestore along with the learning level. The custom instructions are then passed to the handleCodeSnippetFetch function.

  4. Passing Custom Instructions to Cloud Function: The custom instructions are included in the body of the fetch request to the getCodeSnippet cloud function. This allows the cloud function to use the custom instructions when generating the system message for the OpenAI API.

  5. Using Custom Instructions in Cloud Function: The getCodeSnippet cloud function in Untitled-1.js is updated to extract the customInstructions from the request body and use them in the system message. The codeGen custom instruction is specifically used in the system message.

  6. Options Menu Update: The Options Menu (OptionsMenu.js) is updated to include a new option for Assistant Settings. When this option is clicked, the user is navigated to the Assistant Settings page.

Testing

The feature has been manually tested and confirmed to work as expected. The custom instructions set by the user are successfully used in the prompts sent to the OpenAI API.

Impact

This feature enhances the user experience by allowing users to personalize the prompts used in their gameplay. It also provides a foundation for further customization and personalization features in the future.

netlify[bot] commented 10 months ago

Deploy Preview for decode-me ready!

Name Link
Latest commit 9a8a373a6917c1b25a1201c23c791d15044becc5
Latest deploy log https://app.netlify.com/sites/decode-me/deploys/6590be1978fd9100083c0cc5
Deploy Preview https://deploy-preview-33--decode-me.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 configuration.