Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 2.7 KB

santa-instructions.md

File metadata and controls

37 lines (24 loc) · 2.7 KB

🎅 Santa Letters from the North Pole 🎄

In this exercise, you will use GitHub Copilot to create a web app for writing letters to Santa Claus. Let's spread some holiday cheer with code! 🎁✨

Instructions

  1. Create a new GitHub repository for this exercise and clone it to your local machine.

  2. Start a new Copilot "Edits" session in Visual Studio Code. "Edits" is currently in preview. If something goes wrong, you can try the Copilot Chat instead.

  3. These are the prompts you will use for Copilot. After each prompt, you will see the code generated by Copilot. Review the code and make any necessary changes. Then accept the code and move on to the next prompt.

    • I want to create a web app for writing letters to Santa Claus. Create a Streamlit application in a new file called 'santa.py' so the user can write the letter.
    • Change it so the user must provide the name, the age, and the content of the letter.
    • Change it so the user can also tell Santa if they have been good or bad this year using a combo box with several options from 'Very Good' to 'Very Bad' but using friendly words.
    • Change it so the content of the letter is sent to a backend API. Create the backend in another file called 'santa_api.py' using FastAPI. Add the necessary variables to set up the API on the client side.
    • Create a requirements.txt file with the necessary dependencies for the client and the server.
  4. At this point, you should have a working web app that allows the user to write a letter to Santa and send it to a backend API. Ask Copilot how to run the app and the API with this prompt:

    • How can I run the web app and the API?
  5. Now we will add AI to the backend API to generate a response from Santa. Use these prompts:

    • Change the backend so it uses Azure OpenAI. It will use the GPT-4o model to generate a response from Santa. Set up the system prompt so it impersonates Santa as a friendly guy. Generate the prompt so it answers as if it is responding to the users and their letters.
    • Update the backend so it uses the 1.x OpenAI client and "client.chat.completions".
    • Update the backend so it uses dotenv to store the API key and the model base URL. Add the necessary variables to a new .env file.
    • Update the frontend so it receives the response from the backend and shows it to the user.
  6. At this point, you should have a working web app that allows the user to write a letter to Santa, send it to a backend API, and receive a response from Santa. If you are stuck, you can check the solution in the 'solution' folder and run it with the following commands:

    streamlit run santa.py
    uvicorn santa_api:app --reload

Happy coding and happy holidays! 🎄🎅✨