This repository demonstrates practical patterns for building effective LLM-powered systems using pure Python. These patterns are based on real-world implementations and focus on simplicity and composability rather than complex frameworks.
- Pure Python implementation
- No complex frameworks
- Production-ready patterns
- Practical examples
- Detailed documentation
-
Building Blocks
- Basic LLM calls
- Structured output
- Tool use
- Retrieval
-
Workflow Patterns
- Prompt chaining
- Routing
- Parallelization
- Orchestrator-Workers
To get started with this repository, follow these steps:
-
Clone this repository to your local machine:
git clone https://github.com/yourusername/llm-workflow-patterns.git
-
Navigate into the project directory:
cd llm-workflow-patterns
-
Create a virtual environment and activate it:
For Unix/macOS: python3 -m venv venv && source venv/bin/activate
For Windows: python -m venv venv && venv\Scripts\activate
-
Install the dependencies:
pip install -r requirements.txt
-
Create a .env file in the repository root with your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here
-
Run any of the example scripts in the 'patterns/workflows/1-introduction/' directory.
For example, to run the basic motivational quote example:
python patterns/workflows/1-introduction/1-basic.py
-
Explore further examples to learn more about structured output, tool use, and retrieval patterns.
Happy coding!