limeprompt


Namelimeprompt JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/iam-abbas/limeprompt
SummaryLight weight prompting and parsing library for LLM models
upload_time2024-09-30 07:27:08
maintainerNone
docs_urlNone
authorAbbas J
requires_python<4.0,>=3.9
licenseMIT
keywords llm prompt ai openai anthropic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Limeprompt 🍋

[![PyPI version](https://img.shields.io/pypi/v/limeprompt.svg)](https://pypi.org/project/limeprompt/)

Lightweight prompting and parsing library for LLM models.

## What is Limeprompt?

Limeprompt is an opinionated and lightweight prompting and parsing library for LLM models. It aims to make it easy to generate structured outputs from language models. The library is designed to be simple to use, with a single use-case in mind: generating structured outputs from language models. There wont be any support for multi-agent or complex prompting use-cases.

## Installation

```bash
pip install limeprompt
```

## Example Usage

Here's a simple example using Anthropic's Claude:

```python
import logging
from anthropic import Anthropic
from pydantic import BaseModel
from limeprompt import Limeprompt

# Define your output structure
class Email(BaseModel):
    subject: str
    message: str

# Set up your Anthropic client
anthropic_client = Anthropic(api_key='your-api-key')

# Create a Limeprompt instance
lp = Limeprompt(
    model_client=anthropic_client,
    model_name='claude-3-5-sonnet-20240620',
    prompt="Write an email to <name> about <topic>",
    variables={"name": "Alice", "topic": "limes"},
    output_model=Email,
    max_tokens=1024,
    include_chain_of_thought=True,  # Set to False to disable chain of thought
    log_level=logging.INFO  # Set the desired log level
)

# Run and get your results
result = lp.run()

print(f"Subject: {result.output.subject}")
print(f"Message: {result.output.message}")
if result.chain_of_thought:
    print(f"\nChain of Thought:\n{result.chain_of_thought}")
```

Here's an example using OpenAI:

```python
import logging
from openai import OpenAI
from pydantic import BaseModel
from limeprompt import Limeprompt

# Define your output structure
class Email(BaseModel):
    subject: str
    message: str

# Set up your OpenAI client
openai_client = OpenAI(api_key='your-api-key')

# Create a Limeprompt instance
lp = Limeprompt(
    model_client=openai_client,
    model_name='gpt-3.5-turbo',
    prompt="Write an email to <name> about <topic>",
    variables={"name": "Bob", "topic": "lemons"},
    output_model=Email,
    max_tokens=1024,
    include_chain_of_thought=False,  # Disable chain of thought
    log_level=logging.WARNING  # Set log level to WARNING
)

# Run and get your results
result = lp.run()

print(f"Subject: {result.output.subject}")
print(f"Message: {result.output.message}")
```

## Contributing

You are welcome to open issues or submit PRs. Here's my todo list for the library:

- [x] Add support for OpenAI
- [x] Add logging options
- [x] Add ability to disable chain of thought
- [ ] Modularize the prompting techniques
- [ ] Add support for few-shot prompting

## License

Limeprompt is released under the MIT License. Feel free to use it in your projects.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/iam-abbas/limeprompt",
    "name": "limeprompt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "llm, prompt, ai, openai, anthropic",
    "author": "Abbas J",
    "author_email": "abbas@altair.so",
    "download_url": "https://files.pythonhosted.org/packages/cf/a0/4055e510fa09e79b71fe2de43ee6e7639a2e860b0ec3f98721e856e94f9b/limeprompt-0.2.3.tar.gz",
    "platform": null,
    "description": "# Limeprompt \ud83c\udf4b\n\n[![PyPI version](https://img.shields.io/pypi/v/limeprompt.svg)](https://pypi.org/project/limeprompt/)\n\nLightweight prompting and parsing library for LLM models.\n\n## What is Limeprompt?\n\nLimeprompt is an opinionated and lightweight prompting and parsing library for LLM models. It aims to make it easy to generate structured outputs from language models. The library is designed to be simple to use, with a single use-case in mind: generating structured outputs from language models. There wont be any support for multi-agent or complex prompting use-cases.\n\n## Installation\n\n```bash\npip install limeprompt\n```\n\n## Example Usage\n\nHere's a simple example using Anthropic's Claude:\n\n```python\nimport logging\nfrom anthropic import Anthropic\nfrom pydantic import BaseModel\nfrom limeprompt import Limeprompt\n\n# Define your output structure\nclass Email(BaseModel):\n    subject: str\n    message: str\n\n# Set up your Anthropic client\nanthropic_client = Anthropic(api_key='your-api-key')\n\n# Create a Limeprompt instance\nlp = Limeprompt(\n    model_client=anthropic_client,\n    model_name='claude-3-5-sonnet-20240620',\n    prompt=\"Write an email to <name> about <topic>\",\n    variables={\"name\": \"Alice\", \"topic\": \"limes\"},\n    output_model=Email,\n    max_tokens=1024,\n    include_chain_of_thought=True,  # Set to False to disable chain of thought\n    log_level=logging.INFO  # Set the desired log level\n)\n\n# Run and get your results\nresult = lp.run()\n\nprint(f\"Subject: {result.output.subject}\")\nprint(f\"Message: {result.output.message}\")\nif result.chain_of_thought:\n    print(f\"\\nChain of Thought:\\n{result.chain_of_thought}\")\n```\n\nHere's an example using OpenAI:\n\n```python\nimport logging\nfrom openai import OpenAI\nfrom pydantic import BaseModel\nfrom limeprompt import Limeprompt\n\n# Define your output structure\nclass Email(BaseModel):\n    subject: str\n    message: str\n\n# Set up your OpenAI client\nopenai_client = OpenAI(api_key='your-api-key')\n\n# Create a Limeprompt instance\nlp = Limeprompt(\n    model_client=openai_client,\n    model_name='gpt-3.5-turbo',\n    prompt=\"Write an email to <name> about <topic>\",\n    variables={\"name\": \"Bob\", \"topic\": \"lemons\"},\n    output_model=Email,\n    max_tokens=1024,\n    include_chain_of_thought=False,  # Disable chain of thought\n    log_level=logging.WARNING  # Set log level to WARNING\n)\n\n# Run and get your results\nresult = lp.run()\n\nprint(f\"Subject: {result.output.subject}\")\nprint(f\"Message: {result.output.message}\")\n```\n\n## Contributing\n\nYou are welcome to open issues or submit PRs. Here's my todo list for the library:\n\n- [x] Add support for OpenAI\n- [x] Add logging options\n- [x] Add ability to disable chain of thought\n- [ ] Modularize the prompting techniques\n- [ ] Add support for few-shot prompting\n\n## License\n\nLimeprompt is released under the MIT License. Feel free to use it in your projects.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Light weight prompting and parsing library for LLM models",
    "version": "0.2.3",
    "project_urls": {
        "Homepage": "https://github.com/iam-abbas/limeprompt",
        "Repository": "https://github.com/iam-abbas/limeprompt"
    },
    "split_keywords": [
        "llm",
        " prompt",
        " ai",
        " openai",
        " anthropic"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ae045bcb62bdd6c9af77c3246ab5693b2ba7bc3228db68d25bfb622944bf8adf",
                "md5": "0634b82a5aeae95a77f0e1ccc460c490",
                "sha256": "e5d699cab03fb61a79f65ea3297bfffd70a5ff16531ebb058d9496869eaf23f0"
            },
            "downloads": -1,
            "filename": "limeprompt-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0634b82a5aeae95a77f0e1ccc460c490",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 6295,
            "upload_time": "2024-09-30T07:27:07",
            "upload_time_iso_8601": "2024-09-30T07:27:07.096941Z",
            "url": "https://files.pythonhosted.org/packages/ae/04/5bcb62bdd6c9af77c3246ab5693b2ba7bc3228db68d25bfb622944bf8adf/limeprompt-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cfa04055e510fa09e79b71fe2de43ee6e7639a2e860b0ec3f98721e856e94f9b",
                "md5": "7b818a4cea1dbb8c96674561446e029c",
                "sha256": "43ba7030b79481ab6b40673a878397f4e61c0627b4f539134bd1c5c40d4168a1"
            },
            "downloads": -1,
            "filename": "limeprompt-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7b818a4cea1dbb8c96674561446e029c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 4946,
            "upload_time": "2024-09-30T07:27:08",
            "upload_time_iso_8601": "2024-09-30T07:27:08.463351Z",
            "url": "https://files.pythonhosted.org/packages/cf/a0/4055e510fa09e79b71fe2de43ee6e7639a2e860b0ec3f98721e856e94f9b/limeprompt-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-30 07:27:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "iam-abbas",
    "github_project": "limeprompt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "limeprompt"
}
        
Elapsed time: 0.34508s