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.3.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.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for prompt_parser-0.1.3.tar.gz
Algorithm Hash digest
SHA256 dcb9571a73ad91c8ebe1c6190c4690ba30cc9a18096ea07608da3e792bcbf1e4
MD5 e4192f00b54d52b4c9ca519a33eef9e4
BLAKE2b-256 74d5baf42eb27951ae068e404e9bd7c1fdf25232ac11d51e6f963e2fe8936eb0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: prompt_parser-0.1.3-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.12.2

File hashes

Hashes for prompt_parser-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 babb1675a00c715007e2809951a753ee2aafe0c33d3b52dc35395a17cd90ca2a
MD5 177511d16bd31e7d775e69749ce6aa24
BLAKE2b-256 9740766895572ca8c41447f79907e84779a41e3ec4fa152f910e9a7833a48a15

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