Skip to main content

Limeprompt 🍋

PyPI version

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

pip install limeprompt

Example Usage

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

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:

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:

  • Add support for OpenAI
  • Add logging options
  • 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.

Metadata

Release files for limeprompt 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for limeprompt 0.2.3
File Size Uploaded Provenance Actions
limeprompt-0.2.3.tar.gz 4.9 kB Without provenance Details for limeprompt-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for limeprompt 0.2.3
File Interpreter ABI Platform Actions
limeprompt-0.2.3-py3-none-any.whl Python 3 none any Details for limeprompt-0.2.3-py3-none-any.whl

Total release size: 11.2 kB

Release files / limeprompt-0.2.3.tar.gz

Download URL limeprompt-0.2.3.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
43ba7030b79481ab6b40673a878397f4e61c0627b4f539134bd1c5c40d4168a1
BLAKE2b-256 checksum
How to use checksums
cfa04055e510fa09e79b71fe2de43ee6e7639a2e860b0ec3f98721e856e94f9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.9.1 Darwin/23.6.0

Release files / limeprompt-0.2.3-py3-none-any.whl

Download URL limeprompt-0.2.3-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5d699cab03fb61a79f65ea3297bfffd70a5ff16531ebb058d9496869eaf23f0
BLAKE2b-256 checksum
How to use checksums
ae045bcb62bdd6c9af77c3246ab5693b2ba7bc3228db68d25bfb622944bf8adf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.9.1 Darwin/23.6.0

Security for limeprompt 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page