The Python Trainer App is a command-line tool designed to create personalized Python training plans and practice tasks. It uses OpenAI's GPT model to generate custom learning content based on the user's experience level, learning goals, and preferred learning style. This tool is perfect for beginners starting their Python journey or experienced programmers looking to enhance their Python skills.
- Python: The primary programming language used for the project.
- Click: A Python package for creating beautiful command-line interfaces.
- Pydantic: Used for data validation and settings management using Python type annotations.
- OpenAI API: Leveraged to generate personalized training plans and practice tasks.
- python-dotenv: Used for managing environment variables.
- JSON: Used for structured data exchange between the application and the OpenAI API.
- main.py: The entry point of the application, orchestrating the flow of the program.
- cli.py: Handles command-line interface interactions and user input collection.
- config.py: Defines the UserInfo model using Pydantic for structured user data.
- prompt_generator.py: Generates prompts for the OpenAI API based on user information and milestone details.
- openai_utils.py: Manages interactions with the OpenAI API, including sending requests and parsing responses.
- schemas.py: Defines Pydantic models for the training plan structure.
- utils/file_utils.py: Handles file operations, such as creating directories and saving files.
-
Clone the repository:
git clone https://github.com/codingthefuturewithai/python-trainer.git cd python-trainer-app
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up your API key and model:
- This application can use any LLM that exposes the OpenAI API standard. However, please note that to date, this app has only been thoroughly tested with GPT-4o and GPT-4o mini. You have two options:
a) If you want to use an OpenAI model (GPT-4o or GPT-4o mini):
- If you don't have an OpenAI API key, follow these steps to obtain one:
- Go to https://platform.openai.com/signup
- Create an account or sign in if you already have one
- Once logged in, go to https://platform.openai.com/account/api-keys
- Click on "Create new secret key" to generate a new API key
- Copy the generated API key (you won't be able to see it again)
- Copy the
.env_example
file to create a new.env
file in the project root directory:cp .env_example .env
- Open the
.env
file and update the following fields:API_KEY=your_actual_openai_api_key_here BASE_URL=https://api.openai.com/v1/ MODEL_NAME=gpt-4o-mini # or your chosen OpenAI model
b) If you want to use any other OpenAI API-compatible LLM:
-
Obtain the API key and base URL for your chosen LLM service
-
Copy the
.env_example
file to create a new.env
file in the project root directory:cp .env_example .env
-
Open the
.env
file and update the following fields:API_KEY=your_actual_api_key_here BASE_URL=your_llm_service_base_url_here MODEL_NAME=your_chosen_model_name
-
Keep your API key confidential and never share it publicly
-
Run the application:
python -m python_trainer.main
Note: The application uses the GPT-4o mini model. Ensure that your OpenAI account has access to GPT-4o mini.
-
Follow the prompts to input your information and generate a personalized Python training plan.
When you run the application, it will:
- Create a dedicated output directory named
python_trainer_output
in the current working directory. - Prompt you for information about your programming experience, learning goals, and preferred learning style.
- Generate a personalized Python training plan using the OpenAI API.
- Save the training plan as a Markdown file in the output directory.
- Offer to generate a practice task for the first milestone.
- If requested, generate and save the practice task as a separate Markdown file in the output directory.
- Offer to generate practice tasks for all remaining milestones.
- If requested, generate and save practice tasks for all remaining milestones as separate Markdown files in the output directory.
After running the application, you'll find the following files in the python_trainer_output
directory:
training_plan.md
: Contains the personalized Python training plan with multiple milestones.Milestone_1_Practice_Task.md
: Contains a practice task for the first milestone (if you chose to generate it).Milestone_2_Practice_Task.md
,Milestone_3_Practice_Task.md
, etc.: Contains practice tasks for subsequent milestones (if you chose to generate them).
These files will be in Markdown format, making them easy to read and share.
Examples of training plans and practice tasks generated by the app can be found in the sample_outputs
folder of this repository. These samples provide a good illustration of the kind of personalized content the app can generate.
Here's an example of what a user session might look like:
This sample session demonstrates the interactive nature of the app, showing how it prompts for user information, generates a training plan, and creates practice tasks based on the user's preferences.
To view the project documentation and sample outputs as web pages, you can use Python's built-in HTTP server. Follow these steps:
-
Open a terminal and navigate to the project's root directory.
-
Run the following command to start a local web server:
python -m http.server 8080
-
Open a web browser and go to
http://localhost:8080
-
You'll see the Project Home Page with links to:
- Project Documentation
- Sample Outputs from various models
-
Click on the links to navigate through the documentation and sample outputs.
Here's what the Project Docs Web Page looks like:
This setup allows you to easily browse through the project documentation and sample outputs in a web-based format.
Contributions to the Python Trainer App are welcome! Please feel free to submit a Pull Request.
This project is open-source and available under the MIT License.
The Python Trainer App has several exciting possibilities for future enhancements:
-
Dynamic Knowledge Assessment: Implement a short, adaptive quiz to evaluate the user's Python knowledge level. This assessment would be used to further customize and adapt the training plan.
-
Integrated Development Environment: Add the ability to launch a development container for users to execute their Python practice tasks directly within the application. This would provide a consistent and controlled environment for all learners.
-
Task Evaluation: Develop functionality for the trainer to evaluate the learner's completed tasks. This could include automated code review, style checking, and performance analysis.
-
Adaptive Learning: Implement the ability for the trainer to dynamically adapt the training plan based on:
- The learner's perceived progress
- The learner's pace of learning
- Specific requests or redirections from the student
-
Progress Tracking: Create a system to track and visualize the learner's progress over time, providing motivation and insights into areas that may need more focus.
-
Web-based User Interface: Create a UI to allow the user to generate a plan and exercises, update the plan, track progress, etc.
These enhancements would make the Python Trainer App an even more powerful and personalized learning tool, adapting to each user's unique learning journey.