Skip to main content

A simple Python library for parsing LLM prompts.

Project description

Prompt Parser

PyPI PyPI - Downloads

A simple Python library for parsing LLM prompts.

Usage

from prompt_parser import Prompt

prompt = Prompt.parse_from_file("PROMPT_FILE_PATH")

# access the attributes
print(prompt.attributes.temperature) # 0.5
print(prompt.attributes.top_p)  # 0.5
print(prompt.attributes.top_k) # 50
print(prompt.attributes.provider) # openai
print(prompt.attributes.model) # gpt-4
print(prompt.attributes.endpoint) # chat
print(prompt.attributes.max_tokens) # 4096
print(prompt.attributes["unknown"]) # blahblah
print(prompt.system) # Hi from system
print(prompt.user) # Hi from user {custom}
print(prompt.assistant) # Hi from assistant
print(prompt.format_user(custom="Alex")) # "Hi from user Alex"

This is the output of the given prompt file called example.prompt:

---
temperature: 0.5
top_p: 0.5
top_k: 50
max_tokens: 4096
provider: openai
model: gpt-4
endpoint: chat
unknown: blablah
---

<system>
Hi from system
</system>

<user>
Hi from user {custom}
</user>

<assistant>
Hi from assistant
</assistant>

If you don't have a prompt file, you can use the Prompt.parse method to parse a string.

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

prompt_parser-0.1.5.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

prompt_parser-0.1.5-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file prompt_parser-0.1.5.tar.gz.

File metadata

  • Download URL: prompt_parser-0.1.5.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for prompt_parser-0.1.5.tar.gz
Algorithm Hash digest
SHA256 16d238aaba9d7fd5cdd1a329af98243617d5009ff01bae3b80aac869d7a147b6
MD5 10f2e037445a06aba3581b4e2a3de707
BLAKE2b-256 7d0f72fd6599bd62e9b9a1ca80b539fc4a9d2cebc952f9586661078f8682db1f

See more details on using hashes here.

File details

Details for the file prompt_parser-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: prompt_parser-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for prompt_parser-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4bde4acc76cb62bfcf6a01d82657b4dd5bbedd2d64b099f1c4b69014003d9435
MD5 a5210caa40884b7c115029b08576e126
BLAKE2b-256 a8f266f8fd39699ac59162b9cfdb5d61f465c27335ad38f063e9540a3e9e0f78

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