Key Concepts
This agent combines two powerful techniques:- RAG (Retrieval Augmented Generation): Searches a vector database for recipes
- Image Generation: Creates visual guides using DALL-E via OpenAITools
Prerequisites
- Python 3.12+
- Docker (for PostgreSQL with pgvector)
- OpenAI API key (for GPT and DALL-E)
- Cohere API key (for embeddings)
Setup
1
Clone the repository
2
Create and activate virtual environment
3
Install dependencies
4
Set environment variables
5
Start PostgreSQL with pgvector
6
Load recipes into knowledge base
Run the Agent
Basic Recipe
Retrieve a recipe from the knowledge base:- Searching the recipe knowledge base
- Formatted recipe output
- Ingredient and instruction extraction
Visual Guide
Generate a recipe with step-by-step images:- DALL-E image generation for cooking steps
- Saving images to disk
- Complete visual recipe guide
Agent Configuration
| Parameter | Purpose |
|---|---|
model | GPT-5.2 for recipe understanding and generation |
knowledge | Vector database with recipe documents |
OpenAITools | DALL-E image generation |
search_knowledge | Enable knowledge base search |
ReasoningTools | Plan recipe presentation |
How It Works
Recipe Workflow
Knowledge Base
Recipes are stored in PostgreSQL with pgvector using Cohere embeddings:Image Generation
The agent generates images for key cooking steps:| Step Type | Example Prompt |
|---|---|
| Ingredient prep | ”Thai green curry ingredients on cutting board, food photography” |
| Cooking technique | ”Wok with stir-fried vegetables, steam rising, overhead shot” |
| Final dish | ”Plated Thai curry with jasmine rice, garnished with basil” |
Troubleshooting
No recipes found
No recipes found
Ensure recipes are loaded into the knowledge base:
Image generation fails
Image generation fails
Check your OpenAI API key has DALL-E access. Image generation requires a paid OpenAI account.
Database connection refused
Database connection refused
Ensure PostgreSQL is running: