prompt-spec
A lightweight, LinkML-aligned prompt and schema management toolkit for clinical NLP & LLM workflows.
prompt-spec provides:
- Structured prompt templates
- LinkML → Pydantic auto-generation for LLM output schemas
- Validation of few-shot examples within prompts
- A shared format for prompt libraries across collaborating groups
This toolkit is intentionally minimal and designed for stability, reuse, and strong typing when integrating with LLM libraries such as pydantic-instructor
Project Structure
prompt-spec/
├── cli.py ← Main command line interface
├── core/
│ └── prompt_template.py ← Prompt class utilities
├── engines/
│ ├── __init__.py
│ └── instructor_engine.py ← Wrapper function for integrating prompts with ontoGPT via Instructor interface
├── output_models/
│ └── condition_model.yaml ← LinkML schema for defining model outputs - create new endpoint definitions here
├── generated_models/
│ └── (auto-generated pydantic models)
└── prompts/
└── condition_prompt.yaml ← This is where the actual prompt definitions exist
Installation
uv pip install -e .
Usage
1. Defining LinkML output models
Place all LinkML schemas inside prompt-spec/output_models
Example: condition_model.yaml
name: ConditionList
id: https://example.org/condition_model
prefixes:
linkml: https://w3id.org/linkml/
default_range: string
classes:
Condition:
attributes:
label: string
verbatim_name: string
codable_name: string
who_diagnosed: string
is_negated: boolean
ConditionList:
attributes:
conditions:
multivalued: true
range: Condition
2. Generate Pydantic models from LinkML
prompt-spec build-models
This reads all *.yaml schemas in prompt-spec/output_models/ and generates Pydantic classes into prompt-spec/generated_models/.
After running this, you will have files such as:
prompt-spec/generated_models/ConditionList.py
Alternatively, run for just one class update at a time: prompt-spec generate-pydantic-from-linkml output_models/condition_model.yaml
3. Populate prompt template
prompt-spec create-empty-prompt condition_model prompts/condition_prompt.yaml
This produces:
output_model: condition_model
instruction: "<<< fill in your system prompt here >>>"
examples:
example_1:
input: "<<< sample input text here >>>"
output:
conditions: []
4. Validate a prompt against its template
prompt-spec validate-prompt condition_prompt.yaml
Metadata
Release files for prompt-spec 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| prompt_spec-0.1.4.tar.gz | 12.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| prompt_spec-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.1 kB
Release files / prompt_spec-0.1.4.tar.gz
| Download URL | prompt_spec-0.1.4.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8414e5a6942d213f6405d66487d0cf182bf7657181b24cd7b6fe7e8f2446caf2
|
|
BLAKE2b-256 checksum How to use checksums |
242e904ea01123027bfb648ddbd9b651beb5d2836836f7f12b33e4f938c282de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 9, 2026.
Transparency logRelease files / prompt_spec-0.1.4-py3-none-any.whl
| Download URL | prompt_spec-0.1.4-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e12e0cac5a93367974023c37fdace258cc729efd732a20b49a683e477f26f70e
|
|
BLAKE2b-256 checksum How to use checksums |
2096c175c088a1a40611a49ad36ffcce021a170dbee546b292d3564d883df32a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 9, 2026.
Transparency log