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:
---
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.0.tar.gz
(2.2 kB
view details)
File details
Details for the file prompt_parser-0.1.0.tar.gz.
File metadata
- Download URL: prompt_parser-0.1.0.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04bc8f8b554b3e0773316a0638d4ecd938916b454ca96b58bf69ee7cfbfdb5f3
|
|
| MD5 |
ba8919f68bdfd0e7952ffc0521e7ea44
|
|
| BLAKE2b-256 |
f6cfa34af8c9529f19edeeec608cdfaa88376957364fcf8b9a89267c441d2061
|