Skip to content

Commit 7dd1c29

Browse files
authored
Improvement function and tools (#3)
* Improvements to functions and tools implementation * Remove next_steps.txt from Git tracking * Update documentation and examples for tools and functions support * Add tests for tools and functions functionality * Inital commit * - Promptix Studio Fix * Prompts.json Fix * [Bug Fix]: All Tests Working. * Improved Error Handling * - Upgrades * - Upgrades in Builder for tools and logging. * - Clean up for release.
1 parent d4a70fd commit 7dd1c29

39 files changed

+2508
-1268
lines changed

README.md

Lines changed: 139 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -1,164 +1,180 @@
1-
# Promptix
1+
# Promptix 🧩
22

33
[![PyPI version](https://badge.fury.io/py/promptix.svg)](https://badge.fury.io/py/promptix)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
55
[![Python Versions](https://img.shields.io/pypi/pyversions/promptix.svg)](https://pypi.org/project/promptix/)
66
[![PyPI Downloads](https://static.pepy.tech/badge/promptix)](https://pepy.tech/projects/promptix)
77

8-
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.
8+
**Promptix** is a powerful, local-first prompt management system that brings **version control**, **dynamic templating**, and a **visual studio interface** to your LLM workflows.
99

10-
## Features
10+
## 🌟 Why Promptix?
1111

12-
- 🎯 **Built-in Promptix Studio** - Visual prompt management interface (access via `promptix studio`)
13-
- 🔄 **Version Control** - Track changes with live/draft states for each prompt
14-
- 🔌 **Simple Integration** - Easy-to-use Python interface
15-
- 📝 **Variable Substitution** - Dynamic prompts using `{{variable_name}}` syntax
16-
- 🤖 **LLM Integration** - Direct integration with OpenAI and other LLM providers
17-
- 🏃 **Local First** - No external API dependencies
18-
- 🎨 **Web Interface** - Edit and manage prompts through a modern UI
19-
- 🔍 **Schema Validation** - Automatic validation of prompt variables and structure
12+
Managing prompts across multiple applications, models, and use cases can quickly become chaotic. Promptix brings order to this chaos:
2013

21-
## Installation
14+
- **No more prompt spaghetti** in your codebase
15+
- **Version and test prompts** with live/draft states
16+
- **Dynamically customize prompts** based on context variables
17+
- **Edit and manage** through a friendly UI with Promptix Studio
18+
- **Seamlessly integrate** with OpenAI, Anthropic, and other providers
2219

23-
```bash
24-
# Install from PyPI
25-
pip install promptix
20+
## ✨ Key Features
21+
22+
### 🎯 Dynamic Prompt Generation
23+
Create versatile prompts with Promptix's templating system, allowing for context-aware adjustments:
24+
25+
```python
26+
support_prompt = Promptix.get_prompt(
27+
prompt_template="CustomerSupport",
28+
# These variables dynamically modify the prompt
29+
department="Billing",
30+
customer_tier="Premium",
31+
issue_type="refund request",
32+
agent_name="Alex"
33+
)
2634
```
2735

28-
## Quick Start
36+
### 🔄 Version Control Built-in
37+
Keep track of prompt iterations and test new versions without breaking production:
38+
39+
```python
40+
# Get the latest live version (for production)
41+
live_prompt = Promptix.get_prompt("CustomerSupport")
2942

30-
1. Launch Promptix Studio to manage your prompts:
43+
# Test a new draft version in development
44+
draft_prompt = Promptix.get_prompt(
45+
prompt_template="CustomerSupport",
46+
version="v2"
47+
)
48+
```
49+
50+
### 🎨 Promptix Studio
51+
Manage prompts through a clean web interface by simply running:
3152

3253
```bash
3354
promptix studio
3455
```
3556

36-
This opens Promptix Studio in your default browser at `localhost:8501`.
37-
38-
2. Use prompts in your code:
57+
### 🛠️ Fluent Builder API
58+
Create sophisticated prompt configurations with an intuitive builder pattern:
3959

4060
```python
41-
from promptix import Promptix
42-
43-
# Simple prompt with variables
44-
prompt = Promptix.get_prompt(
45-
prompt_template="Greeting",
46-
user_name="John Doe"
47-
)
48-
print(prompt) # Output: Hello John Doe! How can I help you today?
49-
50-
# Advanced prompt with multiple variables
51-
support_prompt = Promptix.get_prompt(
52-
prompt_template="CustomerSupport",
53-
user_name="Jane Smith",
54-
issue_type="password reset",
55-
technical_level="intermediate",
56-
interaction_history="2 previous tickets about 2FA setup"
61+
config = (
62+
Promptix.builder("CustomerSupport")
63+
.with_customer_name("Jane Doe")
64+
.with_department("Technical Support")
65+
.with_priority("high")
66+
.with_tool("ticket_history") # Enable specific tools
67+
.with_tool_parameter("ticket_history", "max_tickets", 5)
68+
.with_memory(conversation_history)
69+
.build()
5770
)
5871
```
5972

60-
## OpenAI Integration
61-
62-
Promptix provides seamless integration with OpenAI's chat models:
73+
### 🤖 Multi-Provider Support
74+
Send your prompts to any LLM provider while maintaining a consistent interface:
6375

6476
```python
65-
from promptix import Promptix
66-
import openai
77+
# OpenAI integration
78+
openai_config = Promptix.builder("AgentPrompt").build()
79+
openai_response = openai_client.chat.completions.create(**openai_config)
6780

68-
client = openai.OpenAI()
81+
# Anthropic integration
82+
anthropic_config = (
83+
Promptix.builder("AgentPrompt")
84+
.for_client("anthropic")
85+
.build()
86+
)
87+
anthropic_response = anthropic_client.messages.create(**anthropic_config)
88+
```
6989

70-
# Prepare model configuration with conversation memory
71-
memory = [
72-
{"role": "user", "content": "I'm having trouble resetting my password"},
73-
{"role": "assistant", "content": "I understand you're having password reset issues. Could you tell me what happens when you try?"}
74-
]
90+
### 🧠 Context-Aware Prompting
91+
Adapt prompts based on dynamic conditions to create truly intelligent interactions:
7592

76-
model_config = Promptix.prepare_model_config(
93+
```python
94+
# Prompt adapts based on user context
95+
prompt = Promptix.get_prompt(
7796
prompt_template="CustomerSupport",
78-
user_name="John Doe",
79-
issue_type="password reset",
80-
technical_level="intermediate",
81-
interaction_history="2 previous tickets about 2FA setup",
82-
issue_description="User is unable to reset their password after multiple attempts",
83-
custom_data={"product_version": "2.1.0", "subscription_tier": "standard"},
84-
memory=memory,
97+
customer_history_length="long" if customer.interactions > 5 else "short",
98+
sentiment="frustrated" if sentiment_score < 0.3 else "neutral",
99+
technical_level=customer.technical_proficiency
85100
)
101+
```
86102

87-
# Use the configuration with OpenAI
88-
response = client.chat.completions.create(**model_config)
103+
## 🚀 Getting Started
104+
105+
### Installation
106+
107+
```bash
108+
pip install promptix
89109
```
90110

91-
## Builder Pattern
111+
### Quick Start
92112

93-
Promptix provides a fluent builder pattern interface for creating model configurations:
113+
1. **Launch Promptix Studio**:
114+
```bash
115+
promptix studio
116+
```
117+
118+
2. **Create your first prompt template** in the Studio UI or in your YAML file.
94119

120+
3. **Use the prompt in your code**:
95121
```python
96122
from promptix import Promptix
97-
import openai
98123

99-
client = openai.OpenAI()
100-
101-
# Using builder pattern for CustomerSupport
102-
model_config = (
103-
Promptix.builder("CustomerSupport")
104-
.with_user_name("John Doe")
105-
.with_issue_type("account_settings")
106-
.with_issue_description("User cannot access account settings page")
107-
.with_technical_level("intermediate")
108-
.with_priority("medium")
109-
.with_memory([
110-
{"role": "user", "content": "I'm having trouble with my account settings"}
111-
])
112-
.build()
124+
# Basic usage
125+
greeting = Promptix.get_prompt(
126+
prompt_template="Greeting",
127+
user_name="Alex"
113128
)
114129

115-
response = client.chat.completions.create(**model_config)
130+
# With OpenAI
131+
from openai import OpenAI
132+
client = OpenAI()
116133

117-
# Using builder pattern for Code Review
118-
code_config = (
119-
Promptix.builder("CodeReview")
120-
.with_code_snippet(code_snippet)
121-
.with_programming_language("Python")
122-
.with_review_focus("Security and SQL Injection")
123-
.with_severity("high")
124-
.build()
134+
model_config = Promptix.prepare_model_config(
135+
prompt_template="CustomerSupport",
136+
customer_name="Jordan Smith",
137+
issue="billing question"
125138
)
126139

127-
# Anthropic Integration
128-
anthropic_config = (
129-
Promptix.builder("CustomerSupport")
130-
.with_version("v5")
131-
.with_user_name("John Doe")
132-
.with_issue_type("account_settings")
133-
.with_memory(memory)
134-
.for_client("anthropic")
135-
.build()
136-
)
140+
response = client.chat.completions.create(**model_config)
137141
```
138142

139-
The builder pattern provides:
140-
- Type-safe configuration building
141-
- Fluent interface for better code readability
142-
- Automatic validation of required fields
143-
- Support for multiple LLM providers
144-
- Clear separation of configuration concerns
143+
## 📊 Real-World Use Cases
145144

146-
## Advanced Usage
145+
### Customer Service
146+
Create dynamic support agent prompts that adapt based on:
147+
- Department-specific knowledge and protocols
148+
- Customer tier and history
149+
- Issue type and severity
150+
- Agent experience level
147151

148-
### Version Control
152+
### Phone Agents
153+
Develop sophisticated call handling prompts that:
154+
- Adjust tone and approach based on customer sentiment
155+
- Incorporate relevant customer information
156+
- Follow department-specific scripts and procedures
157+
- Enable different tools based on the scenario
149158

150-
```python
151-
# Get specific version of a prompt
152-
prompt_v1 = Promptix.get_prompt(
153-
prompt_template="CustomerSupport",
154-
version="v1",
155-
user_name="John"
156-
)
159+
### Content Creation
160+
Generate consistent but customizable content with prompts that:
161+
- Adapt to different content formats and channels
162+
- Maintain brand voice while allowing flexibility
163+
- Include relevant reference materials based on topic
157164

158-
# Get latest live version (default behavior)
159-
prompt_latest = Promptix.get_prompt(
160-
prompt_template="CustomerSupport",
161-
user_name="John"
165+
## 🧪 Advanced Usage
166+
167+
### Custom Tools Configuration
168+
169+
```python
170+
# Configure specialized tools for different scenarios
171+
security_review_config = (
172+
Promptix.builder("CodeReviewer")
173+
.with_code_snippet(code)
174+
.with_review_focus("security")
175+
.with_tool("vulnerability_scanner")
176+
.with_tool("dependency_checker")
177+
.build()
162178
)
163179
```
164180

@@ -167,73 +183,27 @@ prompt_latest = Promptix.get_prompt(
167183
Promptix automatically validates your prompt variables against defined schemas:
168184

169185
```python
170-
# Schema validation ensures correct variable types and values
171186
try:
187+
# Will raise error if technical_level isn't one of the allowed values
172188
prompt = Promptix.get_prompt(
173-
prompt_template="CustomerSupport",
174-
user_name="John",
175-
technical_level="expert" # Will raise error if not in ["beginner", "intermediate", "advanced"]
189+
prompt_template="TechnicalSupport",
190+
technical_level="expert" # Must be in ["beginner", "intermediate", "advanced"]
176191
)
177192
except ValueError as e:
178193
print(f"Validation Error: {str(e)}")
179194
```
180195

181-
### Error Handling
182-
183-
```python
184-
try:
185-
prompt = Promptix.get_prompt(
186-
prompt_template="NonExistentTemplate",
187-
user_name="John"
188-
)
189-
except ValueError as e:
190-
print(f"Error: {str(e)}")
191-
```
192-
193-
## Development
194-
195-
### Setup
196-
197-
1. Clone the repository:
198-
```bash
199-
git clone https://github.com/promptix/promptix-python.git
200-
cd promptix-python
201-
```
202-
203-
2. Create a virtual environment:
204-
```bash
205-
python -m venv venv
206-
source venv/bin/activate # On Windows: venv\Scripts\activate
207-
```
196+
## 🤝 Contributing
208197

209-
3. Install development dependencies:
210-
```bash
211-
pip install -e ".[dev]"
212-
```
213-
214-
### Running Tests
215-
216-
```bash
217-
pytest
218-
```
219-
220-
### Code Style
221-
222-
We use `black` for code formatting and `isort` for import sorting:
223-
224-
```bash
225-
black .
226-
isort .
227-
```
198+
Promptix is a new project aiming to solve real problems in prompt engineering. Your contributions and feedback are highly valued!
228199

229-
## Contributing
200+
1. Star the repository to show support
201+
2. Open issues for bugs or feature requests
202+
3. Submit pull requests for improvements
203+
4. Share your experience using Promptix
230204

231-
1. Fork the repository
232-
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
233-
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
234-
4. Push to the branch (`git push origin feature/amazing-feature`)
235-
5. Open a Pull Request
205+
I'm creating these projects to solve problems I face as a developer, and I'd greatly appreciate your support and feedback!
236206

237-
## License
207+
## 📄 License
238208

239209
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)