Skip to main content

Light weight prompting and parsing library for LLM models

Project description

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.

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

limeprompt-0.2.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

limeprompt-0.2.3-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file limeprompt-0.2.3.tar.gz.

File metadata

  • Download URL: limeprompt-0.2.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.1 Darwin/23.6.0

File hashes

Hashes for limeprompt-0.2.3.tar.gz
Algorithm Hash digest
SHA256 43ba7030b79481ab6b40673a878397f4e61c0627b4f539134bd1c5c40d4168a1
MD5 7b818a4cea1dbb8c96674561446e029c
BLAKE2b-256 cfa04055e510fa09e79b71fe2de43ee6e7639a2e860b0ec3f98721e856e94f9b

See more details on using hashes here.

File details

Details for the file limeprompt-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: limeprompt-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.1 Darwin/23.6.0

File hashes

Hashes for limeprompt-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e5d699cab03fb61a79f65ea3297bfffd70a5ff16531ebb058d9496869eaf23f0
MD5 0634b82a5aeae95a77f0e1ccc460c490
BLAKE2b-256 ae045bcb62bdd6c9af77c3246ab5693b2ba7bc3228db68d25bfb622944bf8adf

See more details on using hashes here.

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