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.1.tar.gz (4.0 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.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prompt_parser-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 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.1.tar.gz
Algorithm Hash digest
SHA256 e3d9d9f944084b2781cfa18fce4a646869fbb1ebdfd2b0c87fcd043461a0a18c
MD5 275b083f3fd3e2a705a63e0cd4c0128b
BLAKE2b-256 bc8b829e50dcec1a765450f6a3436803d45c1a4efd94284fc0d743896b778b92

See more details on using hashes here.

File details

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

File metadata

  • Download URL: prompt_parser-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 079595104d1103fb6cf299ee5422ce704469e9569d091760e0337e16c5b38825
MD5 2382e56958cd7af330f3ee20d8993847
BLAKE2b-256 bb934d41b841f5d3977f355176165233bf9b98df1bd8773560f66aa70e994c71

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