Add an LLM layer to generate and extract structured recipes. You’ll create a lightweight prompt templating system, integrate OpenAI calls behind a small wrapper, and expose an endpoint that generates recipes from ingredients. You’ll also build a CLI workflow to extract a clean recipe from messy HTML and store it into your Django database.
Overview
Syllabus
- Unit 1: Introduction to LLM Calls
- Initialize OpenAI Client
- From Pirate to Tutor: Using System Prompts to Shift AI Persona
- Modify User Prompt to Ask About List Comprehensions in Python
- Temperature Tuning for Diverse LLM Outputs
- OpenAI Model Selection Experiment
- Unit 2: Prompt Structure and Variables
- Implement Template Loading Function
- Replace Template Placeholders with Input Value
- Custom Placeholder Replacement in render_template
- Implement render_prompt_from_file Function
- AI Recipe Generator Prompt Template
- Unit 3: Building LLM Manager
- Complete LLM Manager Setup with OpenAI Client and Logging
- Implement generate_response Prompt Rendering Logic
- Integrate OpenAI Chat Completions into LLM Manager
- Add Robust Error Handling to LLM Manager
- Unit 4: AI Recipe Generation
- Create Prompt Templates for Recipe Generation
- Implement Input Validation for generate_recipe View
- Integrate AI Recipe Generation
- Recipe Response Parsing Foundation
- Implement Recipe Parsing Logic
- Finalize Recipe Generation Endpoint with Structured JSON Output
- Unit 5: Extracting Recipes From HTML
- Create Recipe Extraction Prompt Templates
- Complete extract_recipe_from_html Function
- Implement parse_recipe_string Function for Structured Recipe Extraction
- Store Extracted Recipe Data in Database
- Recipe Extraction Command-line Interface