A module for comprehensive prompt management and orchestration
Project description
PromptBase
PromptBase is a cutting-edge paradigm designed to provide a holistic approach to managing prompts in applications or with users. Traditional LLM (Large Language Model) applications typically have a codebase and a database, with prompts either embedded in the code or stored in the database. However, both approaches have limitations and are not always feasible due to various reasons, such as maintainability, scalability, and flexibility.
PromptBase addresses these challenges by offering a comprehensive solution for prompt management, testing, optimization, and organization. It enables developers and teams to store prompts along with sample inputs and outputs, perform A/B testing, optimize prompts using LLM agents, and much more.
Table of Contents
- Key Features
- Why PromptBase?
- Installation
- Getting Started
- Usage Examples
- API Integration
- Additional Tools
- Contributing
- License
- Contact
Key Features
- Prompt Storage with Samples: Store your prompts along with sample inputs and outputs to maintain context and reference implementations.
- Embedded A/B Testing Tools: Automatically assess prompt quality using embedded LLM-based A/B testing tools.
- Multi-Model Testing: Run prompt tests across multiple models without the need to run your main application.
- LLM Agents for Optimization: Utilize LLM agents to optimize prompts for better performance and results.
- Hierarchical Organization: Organize prompts by hierarchy, type, and version for easy management.
- Safety and Vulnerability Checks: Embedded tools to check prompt safety and reduce vulnerabilities.
- API Access: Optionally provide an API for external applications to interact with the prompt database.
- Annotations and Notes: Enable users to add notes or explanations to prompts for better collaboration.
- Format Conversion: Support converting prompts between different formats or models.
- Auto Translation: Use auto prompt translation tools to support multiple languages.
Why PromptBase?
In traditional LLM applications, prompts are often hard-coded or stored in databases without proper management, making it difficult to maintain, update, or optimize them. PromptBase offers a solution by providing:
- Centralized Management: Keep all your prompts in one place with proper organization and version control.
- Scalability: Efficiently manage hundreds or thousands of prompts without clutter or confusion.
- Collaboration: Enhance teamwork with features like annotations, versioning, and shared access.
- Optimization Tools: Improve the effectiveness of your prompts using built-in testing and optimization features.
- Flexibility: Easily adapt prompts for different models, formats, or languages.
Installation
To install PromptBase, use the following command:
pip install promptbase
Note: Ensure that you have Python 3.7 or higher installed.
Getting Started
Creating Prompts
Begin by creating prompts and storing them in PromptBase along with sample inputs and outputs:
from promptbase import PromptBase
# Initialize PromptBase
pb = PromptBase()
# Create a new prompt
prompt_id = pb.create_prompt(
name="Customer Support Response",
content="Dear {customer_name},\n\nThank you for reaching out...",
samples={
"input": {"customer_name": "John Doe"},
"output": "Dear John Doe,\n\nThank you for reaching out..."
},
tags=["customer support", "email"],
version="1.0"
)
Organizing Prompts
Organize your prompts using hierarchies, tags, and types:
# Add tags or categories
pb.add_tags(prompt_id, ["urgent", "priority"])
# Move prompt to a different category
pb.move_prompt(prompt_id, new_category="Support Emails")
Versioning
Maintain different versions of your prompts:
# Update prompt content and create a new version
pb.update_prompt(
prompt_id,
new_content="Hello {customer_name},\n\nWe appreciate your feedback...",
version="1.1"
)
# Retrieve a specific version
prompt_v1 = pb.get_prompt(prompt_id, version="1.0")
Usage Examples
Running Prompt Tests
Test prompts across multiple models:
# Define models to test
models = ["gpt-3", "gpt-4"]
# Run tests
test_results = pb.run_tests(prompt_id, models=models)
# View results
for model, result in test_results.items():
print(f"Model: {model}")
print(f"Output: {result['output']}")
print(f"Evaluation Score: {result['score']}")
Prompt Optimization
Use LLM agents to optimize prompts:
# Optimize prompt for better clarity
optimized_prompt = pb.optimize_prompt(prompt_id, goal="Improve clarity")
# Save optimized prompt as a new version
pb.update_prompt(
prompt_id,
new_content=optimized_prompt,
version="1.2"
)
Safety Checks
Check prompts for potential vulnerabilities or safety issues:
# Run safety check
safety_report = pb.check_safety(prompt_id)
# View report
print(safety_report)
Annotations and Notes
Add annotations or notes to prompts:
# Add a note
pb.add_annotation(prompt_id, "This prompt needs to be updated for GDPR compliance.")
# Retrieve annotations
annotations = pb.get_annotations(prompt_id)
API Integration
PromptBase provides an optional API for external applications to interact with the prompt database.
# Enable API access
pb.enable_api(access_token="your_api_token")
# Use the API to fetch a prompt
import requests
response = requests.get(
"https://api.promptbase.com/prompts/{prompt_id}",
headers={"Authorization": "Bearer your_api_token"}
)
prompt_data = response.json()
Additional Tools
Format Conversion
Convert prompts between different formats or models:
# Convert prompt to a format compatible with a specific model
converted_prompt = pb.convert_format(prompt_id, target_format="openai")
Auto Translation
Automatically translate prompts to support multiple languages:
# Translate prompt to Spanish
translated_prompt = pb.translate_prompt(prompt_id, target_language="es")
# Save translated prompt
pb.create_prompt(
name="Customer Support Response (Spanish)",
content=translated_prompt,
tags=["customer support", "email", "spanish"],
version="1.0"
)
Contributing
We welcome contributions from the community! If you'd like to contribute to PromptBase, please follow these steps:
- Fork the repository on GitHub.
- Create a new branch for your feature or bug fix.
- Commit your changes with clear and descriptive messages.
- Submit a pull request, detailing the changes you've made and any issues that are fixed.
Please ensure that your code adheres to the project's coding standards and includes appropriate tests.
License
PromptBase is licensed under the MIT License. You are free to use, modify, and distribute this software in accordance with the terms of the license.
Contact
For questions, suggestions, or support, please reach out to:
- Email: support@promptbase.com
- GitHub Issues: https://github.com/your_username/promptbase/issues
Note:
- Replace placeholders like
your_username
and contact details with actual information. - Ensure that you include a
LICENSE
file in your repository specifying the terms under which others can use your code. - Add more detailed instructions or documentation as needed, especially in the code examples.
By providing a comprehensive README, users and contributors can better understand the purpose of PromptBase, how to use it, and how they can contribute to its development.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file promptbase-0.0.1.tar.gz
.
File metadata
- Download URL: promptbase-0.0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aa5ea7e468e5b3c4c45dbf57a66908ccf3521d8e302a29767f4cc3196fbdddf |
|
MD5 | 143844c397965e2866aa7ea8fddf00e9 |
|
BLAKE2b-256 | 31c00d2f87e7f79bd5997f7c607f663fcb7a95cc0282e5a33fba0457c8195369 |
File details
Details for the file promptbase-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: promptbase-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 701b60dd30d87173914b628335e27e1384a7530714b5b0c9a0dd66bd59ea870e |
|
MD5 | a5da56fd22807f55be0ae6966248af66 |
|
BLAKE2b-256 | 28be88ada903bf867ae2c938804af83aace3ac916cdeb18a837f6fd626a13771 |