The QuizManager Generative AI App ⭐️
This project generates quizzes on different topics using generative AI.
Published Aug 9, 2024
This project generates quizzes on different topics using generative AI. The application also grades quizzes taken by users. This project demonstrates the significant impact of well-crafted prompts on AI-generated content, highlighting the importance of prompt engineering in maximizing the potential of generative AI systems.
This project is intended for educational purposes only and not for production use.
Prompt engineering is a crucial skill in working with generative AI models. It involves crafting effective inputs (prompts) to guide AI models in producing desired outputs.
Prompt engineering techniques include zero-shot prompting, few-shot prompting, chain-of-thought prompting, and ReAct (reasoning and acting). This app makes use of the few-shot prompting technique, which provides a few examples of the task before asking the model to perform it.
The following figure shows the architecture of the QuizManager app.
This app utilizes the following patterns:
- Packages: For a hierarchical structuring of the module namespace.
- Application factory: An application factory in Flask is a design pattern useful in scaling Flask projects. It helps in creating and configuring Flask projects flexibly and efficiently, making it easier to develop, test, and maintain as it grows and evolves.
- Blueprints: Blueprints are a way to organize Flask applications into reusable and maintainable units.
- Templates: Templates are files that contain static data as well as placeholders for dynamic data. A template is rendered with specific data to produce a final document. This app makes use of the Jinja template engine.
A selection of models was reviewed, with consideration for use cases, model attributes, maximum tokens, cost, accuracy, performance, and supported languages. Based on this, Anthropic Claude-3 Sonnet was selected as best suited for this use case, as it strikes a balance between intelligence and speed, and it optimizes on speed and cost.
You first need to set up an AWS account and configure your AWS Identity and Access Management (IAM) permissions correctly. You then need to request Anthropic Claude 3 Sonnet model access on Amazon Bedrock. You can find the code samples in the GitHub repository.
Establish a Python venv module virtual environment in the project directory and then proceed to install all necessary dependencies. By using a project-specific virtual environment, you ensure that all dependencies are installed exclusively within that environment, rather than system-wide.
Windows PowerShell
macOS
You should see a parenthesized (
venv
) in front of the prompt after running the command, which indicates that you’ve successfully activated the virtual environment.Once you have activated your virtual environment, proceed with installing Flask.
Next, configure AWS CLI options. If this command is run with no arguments, you will be prompted for configuration values such as your AWS Access Key Id and your AWS Secret Access Key.
Windows PowerShell
macOS
Press CTRL+C or ^C on the terminal.
Application Factory is a function that is responsible for creating the application object and its configuration.
Blueprints are modular components in Flask that encapsulate a collection of related views. They can be easily imported in the init file, providing a convenient way to organize and structure the application's routes and functionality.
The base template is designed to establish a uniform structure for your project while allowing flexibility in certain content areas through Jinja's block functionality.
Template inheritance allows you to build a base “skeleton” template that contains all the common elements of your site and defines blocks that child templates can override.
This guide walks you through how to build a Quiz Manager app powered by generative AI. It explores prompt engineering techniques leveraging the capabilities of Anthropic's Claude 3 Sonnet Large Language Model.