Welcome to the Promptizer documentation! This directory contains comprehensive documentation for the collaborative LLM prompt refinement system.
Complete system architecture, component details, data flow, and design decisions. This document explains:
- System architecture and component interactions
- Data flow and message exchange formats
- Convergence detection mechanisms
- Error handling strategies
- Performance considerations
- Extensibility features
Step-by-step guide for using Promptizer. Includes:
- Quick start instructions
- Installation and configuration
- Basic and advanced usage examples
- Troubleshooting tips
- Integration examples
- Best practices
Detailed example showing a complete refinement process from start to finish. Demonstrates:
- How prompts evolve through iterations
- How both models collaborate
- Convergence detection in action
- Real-world refinement scenarios
- Main README: ../README.md
- GitHub Repository: https://github.com/igor-olikh/promptizer
Promptizer is a collaborative prompt refinement system that uses two independent Large Language Models (OpenAI GPT-4 and Google Gemini) to iteratively improve user-provided prompts until both models agree on the quality.
- Collaborative Refinement: Two LLMs work together to improve prompts
- Automatic Evaluation: Models independently evaluate prompt quality
- Convergence Detection: System stops when both models accept the prompt
- Asynchronous Processing: Parallel API calls for efficiency
- Iteration Control: Prevents infinite loops with configurable max iterations
- State Tracking: Maintains history of all refinements
- File Input/Output: Read prompts from files and automatically save outputs
- Markdown Comparison: Generates color-coded markdown files comparing original vs refined prompts
- Error Handling: Stops immediately on API errors to prevent wasting tokens
- User provides an initial prompt
- Both models (OpenAI and Gemini) refine the prompt in parallel
- The hub selects the best refinement and updates the current prompt
- Both models evaluate whether the prompt is "good enough"
- If both models accept, the process stops
- Otherwise, the loop continues with the refined prompt
- Maximum iterations prevent infinite loops
- Install dependencies:
poetry install - Configure API keys in
.envfile - Run:
poetry run python -m promptizer.main "Your prompt here"
For detailed instructions, see the How-To Guide.
- RefinementHub: Central controller managing state and iterations
- OpenAIClient: Handles OpenAI API interactions
- GeminiClient: Handles Google Gemini API interactions
- PromptRefinementOrchestrator: Main orchestrator coordinating the process
- RefinementRequest: Request sent to models for refinement
- RefinementResponse: Response from models with refined prompt and evaluation
- HubState: Central state tracking all refinement history
The system converges when:
- Both models independently respond with "ACCEPTED" status
- Maximum iterations are reached (safety mechanism)
from promptizer.orchestrator import PromptRefinementOrchestrator
orchestrator = PromptRefinementOrchestrator()
final_prompt, state_summary = await orchestrator.refine(
"Your initial prompt",
verbose=True
)Environment variables in .env:
OPENAI_API_KEY: RequiredGOOGLE_API_KEY: RequiredOPENAI_MODEL: Optional (default:gpt-4)GEMINI_MODEL: Optional (default:gemini-1.5-flash)MAX_ITERATIONS: Optional (default:10)
Contributions are welcome! Please feel free to submit issues or pull requests on GitHub.
MIT License