A simple Python library for parsing LLM prompts.
Project description
Prompt Parser
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
Release history Release notifications | RSS feed
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.2.tar.gz
(4.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prompt_parser-0.1.2.tar.gz.
File metadata
- Download URL: prompt_parser-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf96523046c82dcda0ba835b07253e046f361ceeebef28b6deec75ec7e46e665
|
|
| MD5 |
a0eebcaa447a439ac347d2d2b34fa554
|
|
| BLAKE2b-256 |
37a5d15bd7564151b5de2bbea2a66f17218ef69a9898a1da8ae23c0b4f243654
|
File details
Details for the file prompt_parser-0.1.2-py3-none-any.whl.
File metadata
- Download URL: prompt_parser-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa0d56894068eb9c18536b2ea9baca7c983625d696471ebb5d90fdf905bbff4e
|
|
| MD5 |
c26505ebadfcabee1f90d05a7fb364a9
|
|
| BLAKE2b-256 |
fd49620646c1d1aa63a47405c7cb81bcced4d605654752b61be037b46296afef
|