Skip to main content

Prompt_Framework is a Python package that provides a set of flexible frameworks for prompt engineering. It allows seamless interchangability between various frameworks

Project description

Prompt Framework

Prompt_Framework is a Python package that provides a set of flexible frameworks for prompt engineering. It allows seamless interchangability between various frameworks such as RACE, CARE, APE, CREATE, TAG, CREO, RISE, PAIN, COAST, ROSES, and REACT to build sophisticated prompts for language models with different context and task-based structures.

Link: https://github.com/Subhagatoadak/Prompt_Framework


Features

  • Multiple Framework Support: Includes popular prompt engineering frameworks like RACE, CARE, APE, CREATE, TAG, CREO, RISE, PAIN, COAST, ROSES, and REACT.
  • Seamless Switching: Easily switch between frameworks without writing new prompt logic.
  • Customizable Prompts: Add common parameters during initialization and use framework-specific arguments as needed.
  • Flexible Input: Accepts various parameters, allowing customization of prompts for different use cases.

Installation

To install Prompt_Framework, follow these steps:

1. Install via pip (for local development)

Clone the repository and install the package in editable mode:

git clone https://github.com/yourusername/Prompt_Framework.git
cd Prompt_Framework
pip install -e .

Usage

Once you’ve installed the package, you can easily import and start using the Prompt_Framework in your Python scripts.

1. Import the PromptFramework Class

First, import the PromptFramework class into your Python script:

from Prompt_Framework import Prompt_Framework

# Initialize with common parameters
prompt_tool = Prompt_Framework(context="Customer service inquiry.", output_type="solution", style="polite")

2. Switch to a Framework

To generate a prompt for a specific framework, use the switch_framework() method. For instance, you can switch to the RACE framework:

# Switch to the RACE framework and generate a prompt
prompt_tool.switch_framework("race")
race_prompt = prompt_tool.generate_prompt(
    role="Assistant",
    action="Provide customer service assistance",
    explanation="Provide a detailed and polite response based on the inquiry."
)

print(race_prompt)

Switch Between Frameworks

You can easily switch between different frameworks as per your needs. For example, after generating a RACE prompt, you might want to switch to the APE framework:

# Switch to APE framework and generate a prompt
prompt_tool.switch_framework("ape")
ape_prompt = prompt_tool.generate_prompt(
    action="Solve account issue",
    purpose="Help the user recover their account",
    execution="Provide detailed account recovery instructions."
)

print(ape_prompt)

Customizing Frameworks

Frameworks come with specific requirements for the prompt parameters. For example:

RACE Framework

The RACE framework might require:

  • role: The role of the assistant (e.g., "Assistant").
  • action: What action the assistant should take (e.g., "Provide customer service assistance").
  • explanation: The explanation of the task (e.g., "Provide a detailed and polite response based on the inquiry.").
# Customizing RACE framework
prompt_tool.switch_framework("race")
race_prompt = prompt_tool.generate_prompt(
    role="Customer Service Representative",
    action="Assist with product inquiry",
    explanation="Provide helpful and polite product details in response to customer queries."
)

print(race_prompt)

Frameworks Included

The following prompt engineering frameworks are included in the package:

1. RACE

Role: Specify role Action: Mention action needed Context: Provide background information Explanation: Describe the outcome

2. CARE

Context: Provide background information Action: Mention action needed Result: State the goal Example: Give example outputs

3. APE

Action: Define the job to be done Purpose: State the goal Execution: Describe the desired outcome

4. CREATE

Character: Specify the role Request: Define the job to be done Examples: Provide example outputs Adjustment: Suggestions for improvement Type of Output: Define the output format Extras: Additional context

5. TAG

Task: Define the task Action: Define job to be done Goal: Describe the end goal

6. CREO

Context: Provide background information Request: Define the job to be done Explanation: Explain the task Outcome: Describe the desired outcome

7. RISE

Role: Mention the role Input: Provide context and instructions Steps: Ask for step-by-step instructions Execution: Describe the desired outcome

8. PAIN

Problem: Describe the problem Action: Mention the action needed Information: Request any necessary details Next Steps: Ask for resources or next steps

9. COAST

Context: Provide background information Objective: Define the goal Actions: List actions required Scenario: Describe the scenario Task: Define the task to be completed

10. ROSES

Role: Define the role of the responder Objective: State the expected result Scenario: Provide background context Expected Solution: Describe the expected solution Steps: Ask for the steps to achieve the solution

11. REACT

Context: Provide background information Task: Define the task to be completed Explanation: Describe the task or problem

API Reference

PromptFramework Class Initialization

prompt_tool = Prompt_Framework(context="Context information", output_type="desired_output", style="desired_style")

context (str): Background information for the prompt. output_type (str): The expected output format (e.g., "solution", "steps"). style (str): Style of the output (e.g., "polite", "casual"). switch_framework(framework_name)

Switches to a specific framework.

framework_name (str): The name of the framework to switch to. Options include "race", "ape", "create", etc.

generate_prompt(*args, **kwargs)

Generates a prompt using the currently selected framework.

args: Framework-specific arguments. kwargs: Additional keyword arguments for customization.

Contributing

We welcome contributions! If you'd like to improve this package, feel free to fork the repository, make your changes, and submit a pull request. Please make sure to write tests for new features or bug fixes.

Steps to Contribute:

Fork the repository Clone your fork: git clone https://github.com/yourusername/Prompt_Framework.git Create a new branch: git checkout -b feature-branch Make your changes Push your changes: git push origin feature-branch Create a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prompt_framework-1.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prompt_framework-1.0.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file prompt_framework-1.0.0.tar.gz.

File metadata

  • Download URL: prompt_framework-1.0.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for prompt_framework-1.0.0.tar.gz
Algorithm Hash digest
SHA256 825d58c3866893842ef12b94120076ef602d5e80315a5547889f056cbe8a7489
MD5 a0830e0eb6d494907641f207defcc910
BLAKE2b-256 7d11d2f14a62a25d8a4950d900140bd07b8c65773ebf80549af552c91723930e

See more details on using hashes here.

Provenance

The following attestation bundles were made for prompt_framework-1.0.0.tar.gz:

Publisher: main_publish.yml on Subhagatoadak/Prompt_Framework

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prompt_framework-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for prompt_framework-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1149731843a4013d15a5fa01be2212fda8324d854072db23d0acee1d865fbe57
MD5 22f5bc532d0f6cab0889d05a8cf730fb
BLAKE2b-256 ba3c7cae4b80090cfadc8d7cac5491b1ec16eaf8e3a9e724d40341f0ef4cee10

See more details on using hashes here.

Provenance

The following attestation bundles were made for prompt_framework-1.0.0-py3-none-any.whl:

Publisher: main_publish.yml on Subhagatoadak/Prompt_Framework

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page