promptu


Namepromptu JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryWrite dynamic LLM prompts as natural language
upload_time2024-03-04 00:35:52
maintainer
docs_urlNone
authorDavid
requires_python>=3.9,<4.0
licenseMIT
keywords prompt-engineering llms genai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Promptu

> Write dynamic LLM prompts as natural language

Promptu provides a suite of natural language generation utilities for prompt
engineers, such as truncation, pluralization and natural language list
formatting.

## Project Status

:warning: This project is currently in its infancy. Please report bugs and
expect breaking changes.

## Installation

```sh
pip install promptu
```

## Example

```py
from promptu import join

def find_matching_color(existing_colors):
    return f'What color goes well with {join(items=existing_colors, conjunction="and")}?'

# Prints "What color goes well with blue, purple and white?"
print(find_matching_color(['blue', 'purple', 'white']))
```

## Using in Langchain

```py
runnable = (
    {'prompt': RunnableLambda(find_matching_color)}
    | PromptTemplate.from_template('{prompt}')
    | model
)
runnable.invoke(['blue', 'purple', 'white'])
```

## Prompting Utilities

### `join()`

Formats a list of items as a natural language list.

**Syntax:**

```py
join(items: Iterable, conjunction: str) -> str
```

### `pluralize()`

Selects the singular or plural form of a word based on the number of items.

**Syntax:**

```py
pluralize(singular: str, plural: str, items: Iterable) -> str
```

### `truncate()`

Truncates a string to a maximum length. If the text is longer than the maximum
length, all characters after the maximum length are replaced with the suffix.

**Syntax:**

```py
truncate(
    text: str, max_length: int, mode=TruncateMode.CHARACTER, suffix="..."
) -> str
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "promptu",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "prompt-engineering,llms,genai",
    "author": "David",
    "author_email": "161997989+lintyourcode@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/0c/ac/a14166f66a0515275fbefcda9da9a0c2a48cddf84da5f89818c59c854698/promptu-0.1.0.tar.gz",
    "platform": null,
    "description": "# Promptu\n\n> Write dynamic LLM prompts as natural language\n\nPromptu provides a suite of natural language generation utilities for prompt\nengineers, such as truncation, pluralization and natural language list\nformatting.\n\n## Project Status\n\n:warning: This project is currently in its infancy. Please report bugs and\nexpect breaking changes.\n\n## Installation\n\n```sh\npip install promptu\n```\n\n## Example\n\n```py\nfrom promptu import join\n\ndef find_matching_color(existing_colors):\n    return f'What color goes well with {join(items=existing_colors, conjunction=\"and\")}?'\n\n# Prints \"What color goes well with blue, purple and white?\"\nprint(find_matching_color(['blue', 'purple', 'white']))\n```\n\n## Using in Langchain\n\n```py\nrunnable = (\n    {'prompt': RunnableLambda(find_matching_color)}\n    | PromptTemplate.from_template('{prompt}')\n    | model\n)\nrunnable.invoke(['blue', 'purple', 'white'])\n```\n\n## Prompting Utilities\n\n### `join()`\n\nFormats a list of items as a natural language list.\n\n**Syntax:**\n\n```py\njoin(items: Iterable, conjunction: str) -> str\n```\n\n### `pluralize()`\n\nSelects the singular or plural form of a word based on the number of items.\n\n**Syntax:**\n\n```py\npluralize(singular: str, plural: str, items: Iterable) -> str\n```\n\n### `truncate()`\n\nTruncates a string to a maximum length. If the text is longer than the maximum\nlength, all characters after the maximum length are replaced with the suffix.\n\n**Syntax:**\n\n```py\ntruncate(\n    text: str, max_length: int, mode=TruncateMode.CHARACTER, suffix=\"...\"\n) -> str\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Write dynamic LLM prompts as natural language",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [
        "prompt-engineering",
        "llms",
        "genai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "32d1fad4cd13b069e838c15c30db0e9768e7f9e382feb56191f510e4b47432d1",
                "md5": "013f3f46ad51241fe2635b0b13b0e481",
                "sha256": "45e34299077078f1c797090ebb2989b9b719c29f1574b9eb0e4b698a5e77261c"
            },
            "downloads": -1,
            "filename": "promptu-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "013f3f46ad51241fe2635b0b13b0e481",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 4225,
            "upload_time": "2024-03-04T00:35:50",
            "upload_time_iso_8601": "2024-03-04T00:35:50.664750Z",
            "url": "https://files.pythonhosted.org/packages/32/d1/fad4cd13b069e838c15c30db0e9768e7f9e382feb56191f510e4b47432d1/promptu-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0caca14166f66a0515275fbefcda9da9a0c2a48cddf84da5f89818c59c854698",
                "md5": "fad04b12ff22253b235c11edb346205c",
                "sha256": "f62c5dc8fb7b10f173663488b1cbef4b2dd92a5d415c0c089456712acdd5f911"
            },
            "downloads": -1,
            "filename": "promptu-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "fad04b12ff22253b235c11edb346205c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 3074,
            "upload_time": "2024-03-04T00:35:52",
            "upload_time_iso_8601": "2024-03-04T00:35:52.268834Z",
            "url": "https://files.pythonhosted.org/packages/0c/ac/a14166f66a0515275fbefcda9da9a0c2a48cddf84da5f89818c59c854698/promptu-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-04 00:35:52",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "promptu"
}
        
Elapsed time: 0.23828s