Generate client libraries from prompts.
Project description
PromptSDK
PromptSDK is a CLI tool for generating client code with appropriate type signature from a folder containing prompts in Markdown format.
Installation
uv add prompt-sdk
uv run prompt-sdk --help
Explanation
Prompts are often written in Markdown and can get quite long. Writing them directly into your Python function has some disadvantages. It has no syntax highlighting and also bloats up the Python source file.
def format_prompt(doc_texts: str, doc_types_definitions: str):
return """# Input
The following documents have been uploaded:
{doc_texts}
# Your task
Classify each page in each document into zero or one of the following document types, based on their content:
{doc_types_definitions}
""".format(doc_texts=doc_texts, doc_types_definitions=doc_types_definitions)
agent.run(format_prompt(...))
A naive solution would be to write the system prompt in an external Markdown file and read it in the Python code.
# Input
The following documents have been uploaded:
{doc_texts}
# Your task
Classify each page in each document into zero or one of the following document types, based on their content:
{doc_types_definitions}
prompt_path = PROMPTS_DIR / "classifier.md"
prompt = prompt_path.read_text()
agent.run(prompt.format(...))
The problem is that you need to inspect the Markdown file to know which variables are used in the prompt.
PromptSDK solves this by generating client code from a prompts folder.
ls prompts
# info_extractor.md classifier.md
uv run promptsdk --input prompts --output generated_sdk.py --name SDK
from .generated_sdk import SDK
agent.run(SDK.classifier(...))
Prompt Templates
PromptSDK uses jinja to read the templates.
---
name: "classifier"
description: "The text here appears as a docstring in the generated Python code."
---
# Example
PromptSDK finds variables that are enclosed in two curly braces.
The type of the generated function argument is a String.
{{ example }}
Configuration
PromptSDK looks at pyproject.toml for configuration options.
When not given it looks at the CLI flags.
# pyproject.toml
[tool.prompt-sdk]
input_path = "templates"
output_path = "generated_sdk.py"
use_class = true
class_name = "SDK"
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
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_sdk_python-0.1.2.tar.gz.
File metadata
- Download URL: prompt_sdk_python-0.1.2.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75646d3bd248873b29761869a1f3d6b01b952d71f9da499de64c7ea4976f70ec
|
|
| MD5 |
66fbca3567555eaa769569ce98525c02
|
|
| BLAKE2b-256 |
b64f8cccf4484cbda7f0c1da93ba1c1c93f4a292f9b1db0b23a40a56402a72e9
|
File details
Details for the file prompt_sdk_python-0.1.2-py3-none-any.whl.
File metadata
- Download URL: prompt_sdk_python-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0deea1161c18d36f003f571811fd6dab7ffbd58fd39efa986de6d80fce3044bb
|
|
| MD5 |
8a986705a383d421377f2b7dff200f58
|
|
| BLAKE2b-256 |
4b30f9dec49ded5af4a7dd475bf606836f245128f3dce679256db3f75c57df10
|