A Python library for managing and using prompts with Promptix Studio integration. Promptix makes it easy to manage, version, and use prompts in your applications with a built-in web interface.
- π― Built-in Promptix Studio - Visual prompt management interface (access via
promptix studio
) - π Version Control - Track changes with live/draft states for each prompt
- π Simple Integration - Easy-to-use Python interface
- π Variable Substitution - Dynamic prompts using
{{variable_name}}
syntax - π€ LLM Integration - Direct integration with OpenAI and other LLM providers
- π Local First - No external API dependencies
- π¨ Web Interface - Edit and manage prompts through a modern UI
- π Schema Validation - Automatic validation of prompt variables and structure
# Install from PyPI
pip install promptix
- Launch Promptix Studio to manage your prompts:
promptix studio
This opens Promptix Studio in your default browser at localhost:8501
.
- Use prompts in your code:
from promptix import Promptix
# Simple prompt with variables
prompt = Promptix.get_prompt(
prompt_template="Greeting",
user_name="John Doe"
)
print(prompt) # Output: Hello John Doe! How can I help you today?
# Advanced prompt with multiple variables
support_prompt = Promptix.get_prompt(
prompt_template="CustomerSupport",
user_name="Jane Smith",
issue_type="password reset",
technical_level="intermediate",
interaction_history="2 previous tickets about 2FA setup"
)
Promptix provides seamless integration with OpenAI's chat models:
from promptix import Promptix
import openai
client = openai.OpenAI()
# Prepare model configuration with conversation memory
memory = [
{"role": "user", "content": "I'm having trouble resetting my password"},
{"role": "assistant", "content": "I understand you're having password reset issues. Could you tell me what happens when you try?"}
]
model_config = Promptix.prepare_model_config(
prompt_template="CustomerSupport",
user_name="John Doe",
issue_type="password reset",
technical_level="intermediate",
interaction_history="2 previous tickets about 2FA setup",
issue_description="User is unable to reset their password after multiple attempts",
custom_data={"product_version": "2.1.0", "subscription_tier": "standard"},
memory=memory,
)
# Use the configuration with OpenAI
response = client.chat.completions.create(**model_config)
Promptix provides a fluent builder pattern interface for creating model configurations:
from promptix import Promptix
import openai
client = openai.OpenAI()
# Using builder pattern for CustomerSupport
model_config = (
Promptix.builder("CustomerSupport")
.with_user_name("John Doe")
.with_issue_type("account_settings")
.with_issue_description("User cannot access account settings page")
.with_technical_level("intermediate")
.with_priority("medium")
.with_memory([
{"role": "user", "content": "I'm having trouble with my account settings"}
])
.build()
)
response = client.chat.completions.create(**model_config)
# Using builder pattern for Code Review
code_config = (
Promptix.builder("CodeReview")
.with_code_snippet(code_snippet)
.with_programming_language("Python")
.with_review_focus("Security and SQL Injection")
.with_severity("high")
.build()
)
# Anthropic Integration
anthropic_config = (
Promptix.builder("CustomerSupport")
.with_version("v5")
.with_user_name("John Doe")
.with_issue_type("account_settings")
.with_memory(memory)
.for_client("anthropic")
.build()
)
The builder pattern provides:
- Type-safe configuration building
- Fluent interface for better code readability
- Automatic validation of required fields
- Support for multiple LLM providers
- Clear separation of configuration concerns
# Get specific version of a prompt
prompt_v1 = Promptix.get_prompt(
prompt_template="CustomerSupport",
version="v1",
user_name="John"
)
# Get latest live version (default behavior)
prompt_latest = Promptix.get_prompt(
prompt_template="CustomerSupport",
user_name="John"
)
Promptix automatically validates your prompt variables against defined schemas:
# Schema validation ensures correct variable types and values
try:
prompt = Promptix.get_prompt(
prompt_template="CustomerSupport",
user_name="John",
technical_level="expert" # Will raise error if not in ["beginner", "intermediate", "advanced"]
)
except ValueError as e:
print(f"Validation Error: {str(e)}")
try:
prompt = Promptix.get_prompt(
prompt_template="NonExistentTemplate",
user_name="John"
)
except ValueError as e:
print(f"Error: {str(e)}")
- Clone the repository:
git clone https://github.com/promptix/promptix-python.git
cd promptix-python
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install development dependencies:
pip install -e ".[dev]"
pytest
We use black
for code formatting and isort
for import sorting:
black .
isort .
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.