semvec/pypi-packages huggingface dataset:
prompt-defender-aws-defences 0.1.26
Prompt Defender. A package to help you defend against prompt injection attacks.
Requires Python: <4.0,>=3.9

# README

## Prompt Defender AWS Defences Library

Welcome to the **Prompt Defender AWS Defences** library. This library is designed to help you defend against prompt injection attacks by leveraging AWS services such as AWS Comprehend and SageMaker. The library is written in Python and can be easily installed via pip.

### Installation

You can install the library using pip:

```bash
pip install prompt-defender-aws-defences
```

### Usage

This library provides two main classes to help in detecting and preventing prompt injection attacks:

1. **AwsPIIScannerWallExecutor**: This class uses AWS Comprehend to scan text for Personally Identifiable Information (PII).
2. **SagemakerWallExecutor**: This class calls a remote SageMaker endpoint to validate the prompt.

#### Example

You can find example usage in the `example.py` file.

```python
from prompt_defender_aws_defences import AwsPIIScannerWallExecutor, SagemakerWallExecutor

# Example usage of AwsPIIScannerWallExecutor
pii_executor = AwsPIIScannerWallExecutor()
validation_result = pii_executor.is_user_input_safe("Your text to scan here")
print(validation_result)

# Example usage of SagemakerWallExecutor
sagemaker_executor = SagemakerWallExecutor(sagemaker_name="your-sagemaker-endpoint")
validation_result = sagemaker_executor.is_user_input_safe("Your text to validate here")
print(validation_result)
```

### Directory Structure

The main class files are located in the `prompt_defender_aws_defences` directory:

- `prompt_defender_aws_defences/__init__.py`: Initializes the package and imports the main executors.
- `prompt_defender_aws_defences/wall/pii_detection.py`: Contains the `AwsPIIScanner` and `AwsPIIScannerWallExecutor` classes.
- `prompt_defender_aws_defences/wall/sagemaker_inference.py`: Contains the `RemoteSagemakerCaller` and `SagemakerWallExecutor` classes.
- `prompt_defender_aws_defences/wall/shared.py`: Defines shared utilities such as `MatchLevel` and `match_level_for_score`.
- `prompt_defender_aws_defences/wall/__init__.py`: Initializes the wall module and imports the necessary executors.

### License

This project is licensed under the Apache License. See the [LICENSE](LICENSE) file for more details.

### Contact

For any questions or issues, please contact the project owner at [admin@safetorun.com](mailto:admin@safetorun.com).

### Contributing

Contributions are welcome! Please refer to the project's [GitHub Issues page](https://github.com/safetorun/PromptDefender-py/issues) for any open issues or feature requests.

### Additional Information

For more details, please visit the project's [Homepage](https://github.com/safetorun/PromptDefender-py).

We hope you find this library useful in defending against prompt injection attacks!

---

Happy coding! 🛡️
prompt-defender-llm-defences 0.1.26
Prompt Defender. A package to help you defend against prompt injection attacks.
Requires Python: <4.0,>=3.9

# Prompt Defender
![PyPI](https://img.shields.io/pypi/v/prompt-defender)
![PyPI](https://img.shields.io/pypi/v/prompt-defender-llm-defences)

Read the documentation at [Prompt Defender - Docs](https://promptshield.readme.io/docs)

## Installation

```pip install prompt-defender prompt-defender-llm-defences```

## Running tests


To the run the tests, you'll need an openAI API Key. 

```bash
export OPENAI_API_KEY=<your API key>
make test
```
prompt-defender 0.1.26
Prompt Defender. A package to help you defend against prompt injection attacks.
Requires Python: <4.0,>=3.9

# README

# Prompt Defender Library

Welcome to the **Prompt Defender** library, a Python package designed to help you defend against prompt injection attacks. This library provides a robust framework for generating safe prompts and validating user inputs to ensure the security of your applications.

## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
  - [Examples](#examples)
- [Modules](#modules)
  - [Defence](#defence)
  - [Keep](#keep)
  - [Wall](#wall)
  - [Drawbridge](#drawbridge)
- [Testing](#testing)
- [License](#license)
- [Contact](#contact)

## Installation

You can install the library using pip:

```bash
pip install prompt-defender
```

## Usage

The Prompt Defender library is designed to be easy to integrate into your Python applications. Below is an example of how to use the library:

### Examples

The `example.py` file contains several examples demonstrating how to use the library. Here is a simple example to get you started:

```python
from prompt_defender import Defence, build_drawbridge, build_xml_scanner, build_prompt_validator

# Configure the defence mechanisms
defence = Defence(
  wall=[
    build_xml_scanner(),
    build_prompt_validator(max_length=100)
  ],
  keep=None,
  drawbridge=build_drawbridge(allow_unsafe_scripts=False)
)

# Prepare a prompt
safe_prompt_response = defence.prepare_prompt("Your job is to answer user questions about cats {user_question}", False)

# Check user input
is_safe, cleaned_instruction = defence.is_user_input_safe("What is the best cat? " + safe_prompt_response.safe_prompt)

# Check prompt output
output_response = defence.check_prompt_output("The best cat is a Maine Coon.")
print(f"Output is safe: {output_response.is_safe}, Cleaned response: {output_response.cleaned_response}")
```

For more detailed examples, please refer to the `example.py` file.

## Modules

### Defence

The `Defence` class integrates several defensive mechanisms against potential prompt injection and jailbreak attempts.

### Keep

The `Keep` module is responsible for generating safe prompts and includes the `RemoteKeepExecutor` class for interacting with remote services.

### Wall

The `Wall` module contains various validators for checking user input and includes classes such as `PromptValidator`, `BasicXmlScanner`, and `PromptDefenderClient`.

### Drawbridge

The `Drawbridge` module provides mechanisms for validating and cleaning the responses of a language model, including the `DefaultDrawbridgeExecutor` class.

## Testing

Unit tests are included in the `tests` directory. You can run the tests using `unittest`:

```bash
python -m unittest discover -s prompt_defender/tests
```

## License

This project is licensed under the Apache License. See the LICENSE file for more details.

## Contact

For any questions, issues, or contributions, please contact the project owner at [admin@safetorun.com](mailto:admin@safetorun.com).

---

Thank you for using Prompt Defender! Together, we can create safer applications.
nlrest 0.1.3
A CLI tool to convert natural language to REST API queries.
Requires Python: >=3.6


# nlrest

## Description

`nlrest` is a Python Command Line Interface (CLI) tool that allows users to convert natural language descriptions into REST API queries and execute them. It uses OpenAI's GPT-3.5 Turbo model to interpret natural language and generate the details of the REST API call, including the method, URL, headers, and request body.

## Installation

### Prerequisites

- Python 3.6 or higher
- An OpenAI API key

### Install from PyPI

You can install `nlrest` directly from PyPI:

```bash
pip install nlrest
```

### Set Up Environment Variable

Before using `nlrest`, set the `OPENAI_API_KEY` environment variable with your OpenAI API key:

```bash
export OPENAI_API_KEY='your-api-key-here'
```

## Usage

### Basic Usage

To use `nlrest`, run the command followed by the `-p` option and your natural language prompt:

```bash
nlrest -p "Your natural language instruction here"
```

Example:

```bash
nlrest -p "Fetch the latest news from NewsAPI"
```

The tool will output the response from the executed REST API call.

### Example Prompts

- "Fetch the latest stock prices from the Finance API."
- "Post a new message to my social media account saying 'Hello World!'."

## Features

- Converts natural language to REST API query details.
- Supports various HTTP methods (GET, POST, PUT, DELETE).
- Executes the REST API requests and displays the response.

## Contributing

Contributions to `nlrest` are welcome! Please feel free to submit pull requests or open issues to improve the tool or add new features.

## License

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