Skip to main content

Inferready helps you combine all the components of your prompt into a single LLM-ready payload

Project description

infeready

Infeready helps you craft efficient LLM-ready prompts from smaller building blocks. Add history, data sources, ICL examples, and apply filters such as prompt injection scanning, PII redaction or access control over the entire input.

Quick Install

With pip:

pip install infeready

Examples

Example invocation showcasing varying sources and filters (not all of which may be implemented at the time)

from infeready import user_prompt, SystemPrompt
from infeready.sources import PDF, GoogleDrive, LangchainDocuments
from infeready.filters import PromptInject, Anonymize, AccessControl

examples = infeready.load_examples("./icl_examples.json")

system = SystemPrompt("You are LawyerGPT, and must estimate the most likely judicial outcome for a user provided case. Consider all provided documents and respond concisely."}

prompt = user_prompt(
    "determine the most likely legal outcome for the provided case",
    history=[system],
    examples=examples,
    sources=[
        PDF('case_file.pdf'),
        GoogleDrive("credentials.json")
        LangchainDocuments(get_langchain_docs()) # DIY fetch from vectorstore
    ],
    filters=[PromptInject(provider="epoch"), Anonymize(provider="local")],
    max_token_count=10000
)

# We can use the prompt in any LLM or library format
from openai import OpenAI
client = OpenAI()
stream = client.chat.completions.create(
    model="gpt-4",
    messages=prompt.to_openai_messages(),
    stream=True,
)

Example invocation with the openai messages format

from infeready import messages_prompt
from infeready.sources import PDF, GoogleDrive, FromDocuments
from infeready.filters import PromptInject, Anonymize, AccessControl

examples = infeready.load_examples("./icl_examples.json")

messages = [
    {
        "role": "system",
        "content": "You are LawyerGPT, and must estimate the most likely judicial outcome for a user provided case. Consider all provided documents and respond concisely."
    },
    {
        "role": "user",
        "content": "determine the most likely legal outcome for the provided case"
    }
]

prompt = messages_prompt(
    messages,
    examples=examples,
    sources=[
        PDF('case_file.pdf'),
        GoogleDrive("credentials.json")
        FromDocuments(get_langchain_docs()) # DIY fetch from vectorstore
    ],
    filters=[PromptInject(provider="epoch"), Anonymize(provider="local")],
    max_token_count=10000
)


# Use the prompt with langchain
from langchain_openai import ChatOpenAI

model = ChatOpenAI()
chain = prompt.to_langchain_messages() | model
chain.invoke()

Features

  • Unit test creation: test prompt creation consistently every time
  • Security and privacy scanners
  • Compatible with openai and langchain input formats

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

infeready-0.0.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

infeready-0.0.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file infeready-0.0.1.tar.gz.

File metadata

  • Download URL: infeready-0.0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.6 Darwin/23.4.0

File hashes

Hashes for infeready-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c80176fd6c974ce6bcd746d52e1ac5a9a0c4a8229d3853060c798e3ab9344c50
MD5 6c2563693c44bb8eb81362ca4ed7a553
BLAKE2b-256 4d42935ac5fd87854343627b599f43896c86f01d5d308b1a3d69cfa401852de9

See more details on using hashes here.

File details

Details for the file infeready-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: infeready-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.6 Darwin/23.4.0

File hashes

Hashes for infeready-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4b4c0b21c1383eabce4d56cf7251c0d4099f68adb610ef1cf3594a19237af5b
MD5 a3c3dd17f0f3c37a2202799d5701075e
BLAKE2b-256 4ef1b6e231cafcf71c2985739f901e805e478382d42cffa095453b8ca4ee670a

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