Name | pal-framework JSON |
Version |
0.0.4
JSON |
| download |
home_page | None |
Summary | Prompt Assembly Language - A framework for managing LLM prompts as versioned, composable software artifacts |
upload_time | 2025-08-13 15:37:00 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.12 |
license | MIT License
Copyright (c) 2025 NicolΓ‘s Iglesias <nfiglesias@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. |
keywords |
ai
claude
gpt
llm
prompt-engineering
prompts
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PAL - Prompt Assembly Language
[](https://www.python.org/downloads/)
[](LICENSE)
[](https://github.com/cyqlelabs/pal/actions/workflows/ci.yml)
[](https://codecov.io/gh/cyqlelabs/pal)
PAL (Prompt Assembly Language) is a framework for managing LLM prompts as versioned, composable software artifacts. It treats prompt engineering with the same rigor as software engineering, focusing on modularity, versioning, and testability.
See also the [NodeJS version](https://github.com/cyqlelabs/pal-node) of PAL (_WIP_)
## β‘ Features
- **Modular Components**: Break prompts into reusable, versioned components
- **Template System**: Powerful Jinja2-based templating with variable injection
- **Dependency Management**: Import and compose components from local files or URLs
- **LLM Integration**: Built-in support for OpenAI, Anthropic, and custom providers
- **Evaluation Framework**: Comprehensive testing system for prompt validation
- **Rich CLI**: Beautiful command-line interface with syntax highlighting
- **Flexible Extensions**: Use `.pal/.pal.lib` or `.yml/.lib.yml` extensions
- **Type Safety**: Full Pydantic v2 validation for all schemas
- **Observability**: Structured logging and execution tracking
## π¦ Installation
```bash
# Install with uv (recommended)
uv add pal-framework
# Or with pip
pip install pal-framework
```
## π Project Structure
```
my_pal_project/
βββ prompts/
β βββ classify_intent.pal # or .yml for better IDE support
β βββ code_review.pal
βββ libraries/
β βββ behavioral_traits.pal.lib # or .lib.yml
β βββ reasoning_strategies.pal.lib
β βββ output_formats.pal.lib
βββ evaluation/
βββ classify_intent.eval.yaml
```
## π Quick Start
### 1. Create a Component Library
For a detailed guide, [read this](https://prompt-assembly-language-pal.readthedocs.io/en/latest/guides/component-libraries.html).
```yaml
# libraries/traits.pal.lib
pal_version: "1.0"
library_id: "com.example.traits"
version: "1.0.0"
description: "Behavioral traits for AI agents"
type: "trait"
components:
- name: "helpful_assistant"
description: "A helpful and polite assistant"
content: |
You are a helpful, harmless, and honest AI assistant. You provide
accurate information while being respectful and considerate.
```
### 2. Create a Prompt Assembly
For a detailed guide, [read this](https://prompt-assembly-language-pal.readthedocs.io/en/latest/guides/writing-prompts.html).
```yaml
# prompts/classify_intent.pal
pal_version: "1.0"
id: "classify-user-intent"
version: "1.0.0"
description: "Classifies user queries into intent categories"
imports:
traits: "./libraries/traits.pal.lib"
variables:
- name: "user_query"
type: "string"
description: "The user's input query"
- name: "available_intents"
type: "list"
description: "List of available intent categories"
composition:
- "{{ traits.helpful_assistant }}"
- ""
- "## Task"
- "Classify this user query into one of the available intents:"
- ""
- "**Available Intents:**"
- "{% for intent in available_intents %}"
- "- {{ intent.name }}: {{ intent.description }}"
- "{% endfor %}"
- ""
- "**User Query:** {{ user_query }}"
```
### 3. Use the CLI
```bash
# Compile a prompt
pal compile prompts/classify_intent.pal --vars '{"user_query": "Take me to google.com", "available_intents": [{"name": "navigate", "description": "Go to URL"}]}'
# Execute with an LLM
pal execute prompts/classify_intent.pal --model gpt-4 --provider openai --vars '{"user_query": "Take me to google.com", "available_intents": [{"name": "navigate", "description": "Go to URL"}]}'
# Validate PAL files
pal validate prompts/ --recursive
# Run evaluation tests
pal evaluate evaluation/classify_intent.eval.yaml
```
### 4. Use Programmatically
```python
import asyncio
from pal import PromptCompiler, PromptExecutor, MockLLMClient
async def main():
# Set up components
compiler = PromptCompiler()
llm_client = MockLLMClient("Mock response")
executor = PromptExecutor(llm_client)
# Compile prompt
variables = {
"user_query": "What's the weather?",
"available_intents": [{"name": "search", "description": "Search for info"}]
}
compiled_prompt = await compiler.compile_from_file(
"prompts/classify_intent.pal",
variables
)
print("Compiled Prompt:", compiled_prompt)
asyncio.run(main())
```
## π§ͺ Evaluation System
Create test suites to validate your prompts:
```yaml
# evaluation/classify_intent.eval.yaml
pal_version: "1.0"
prompt_id: "classify-user-intent"
target_version: "1.0.0"
test_cases:
- name: "navigation_test"
variables:
user_query: "Go to google.com"
available_intents: [{ "name": "navigate", "description": "Visit URL" }]
assertions:
- type: "json_valid"
- type: "contains"
config:
text: "navigate"
```
## ποΈ Architecture
PAL follows modern software engineering principles:
- **Schema Validation**: All files are validated against strict Pydantic schemas
- **Dependency Resolution**: Automatic import resolution with circular dependency detection
- **Template Engine**: Jinja2 for powerful variable interpolation and logic
- **Observability**: Structured logging with execution metrics and cost tracking
- **Type Safety**: Full type hints and runtime validation
## π οΈ CLI Commands
| Command | Description |
| -------------- | ------------------------------------------------- |
| `pal compile` | Compile a PAL file into a prompt string |
| `pal execute` | Compile and execute a prompt with an LLM |
| `pal validate` | Validate PAL files for syntax and semantic errors |
| `pal evaluate` | Run evaluation tests against prompts |
| `pal info` | Show detailed information about PAL files |
## π§© Component Types
PAL supports different types of reusable components:
- **persona**: AI personality and role definitions
- **task**: Specific instructions or objectives
- **context**: Background information and knowledge
- **rules**: Constraints and guidelines
- **examples**: Few-shot learning examples
- **output_schema**: Output format specifications
- **reasoning**: Thinking strategies and methodologies
- **trait**: Behavioral characteristics
- **note**: Documentation and comments
## π€ Contributing
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
## π License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## π Support
- π [Documentation](https://prompt-assembly-language-pal.readthedocs.io)
- π [Issues](https://github.com/cyqlelabs/pal/issues)
- π¬ [Discussions](https://github.com/cyqlelabs/pal/discussions)
## πΊοΈ Roadmap
- [ ] **PAL Registry**: Centralized repository for sharing components
- [ ] **Visual Builder**: Drag-and-drop prompt composition interface
- [ ] **IDE Extensions**: VS Code and other editor integrations
Raw data
{
"_id": null,
"home_page": null,
"name": "pal-framework",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "ai, claude, gpt, llm, prompt-engineering, prompts",
"author": null,
"author_email": "Nicolas Iglesias <nfiglesias@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/72/57/5fa76a940d5cbd06e83f9791b28b8ee16f7f948776bd8e2ad38c03f75ae8/pal_framework-0.0.4.tar.gz",
"platform": null,
"description": "# PAL - Prompt Assembly Language\n\n[](https://www.python.org/downloads/)\n[](LICENSE)\n[](https://github.com/cyqlelabs/pal/actions/workflows/ci.yml)\n[](https://codecov.io/gh/cyqlelabs/pal)\n\nPAL (Prompt Assembly Language) is a framework for managing LLM prompts as versioned, composable software artifacts. It treats prompt engineering with the same rigor as software engineering, focusing on modularity, versioning, and testability.\n\nSee also the [NodeJS version](https://github.com/cyqlelabs/pal-node) of PAL (_WIP_)\n\n## \u26a1 Features\n\n- **Modular Components**: Break prompts into reusable, versioned components\n- **Template System**: Powerful Jinja2-based templating with variable injection\n- **Dependency Management**: Import and compose components from local files or URLs\n- **LLM Integration**: Built-in support for OpenAI, Anthropic, and custom providers\n- **Evaluation Framework**: Comprehensive testing system for prompt validation\n- **Rich CLI**: Beautiful command-line interface with syntax highlighting\n- **Flexible Extensions**: Use `.pal/.pal.lib` or `.yml/.lib.yml` extensions\n- **Type Safety**: Full Pydantic v2 validation for all schemas\n- **Observability**: Structured logging and execution tracking\n\n## \ud83d\udce6 Installation\n\n```bash\n# Install with uv (recommended)\nuv add pal-framework\n\n# Or with pip\npip install pal-framework\n```\n\n## \ud83d\udcc1 Project Structure\n\n```\nmy_pal_project/\n\u251c\u2500\u2500 prompts/\n\u2502 \u251c\u2500\u2500 classify_intent.pal # or .yml for better IDE support\n\u2502 \u2514\u2500\u2500 code_review.pal\n\u251c\u2500\u2500 libraries/\n\u2502 \u251c\u2500\u2500 behavioral_traits.pal.lib # or .lib.yml\n\u2502 \u251c\u2500\u2500 reasoning_strategies.pal.lib\n\u2502 \u2514\u2500\u2500 output_formats.pal.lib\n\u2514\u2500\u2500 evaluation/\n \u2514\u2500\u2500 classify_intent.eval.yaml\n```\n\n## \ud83d\ude80 Quick Start\n\n### 1. Create a Component Library\n\nFor a detailed guide, [read this](https://prompt-assembly-language-pal.readthedocs.io/en/latest/guides/component-libraries.html).\n\n```yaml\n# libraries/traits.pal.lib\npal_version: \"1.0\"\nlibrary_id: \"com.example.traits\"\nversion: \"1.0.0\"\ndescription: \"Behavioral traits for AI agents\"\ntype: \"trait\"\n\ncomponents:\n - name: \"helpful_assistant\"\n description: \"A helpful and polite assistant\"\n content: |\n You are a helpful, harmless, and honest AI assistant. You provide\n accurate information while being respectful and considerate.\n```\n\n### 2. Create a Prompt Assembly\n\n\nFor a detailed guide, [read this](https://prompt-assembly-language-pal.readthedocs.io/en/latest/guides/writing-prompts.html).\n\n```yaml\n# prompts/classify_intent.pal\npal_version: \"1.0\"\nid: \"classify-user-intent\"\nversion: \"1.0.0\"\ndescription: \"Classifies user queries into intent categories\"\n\nimports:\n traits: \"./libraries/traits.pal.lib\"\n\nvariables:\n - name: \"user_query\"\n type: \"string\"\n description: \"The user's input query\"\n - name: \"available_intents\"\n type: \"list\"\n description: \"List of available intent categories\"\n\ncomposition:\n - \"{{ traits.helpful_assistant }}\"\n - \"\"\n - \"## Task\"\n - \"Classify this user query into one of the available intents:\"\n - \"\"\n - \"**Available Intents:**\"\n - \"{% for intent in available_intents %}\"\n - \"- {{ intent.name }}: {{ intent.description }}\"\n - \"{% endfor %}\"\n - \"\"\n - \"**User Query:** {{ user_query }}\"\n```\n\n### 3. Use the CLI\n\n```bash\n# Compile a prompt\npal compile prompts/classify_intent.pal --vars '{\"user_query\": \"Take me to google.com\", \"available_intents\": [{\"name\": \"navigate\", \"description\": \"Go to URL\"}]}'\n\n# Execute with an LLM\npal execute prompts/classify_intent.pal --model gpt-4 --provider openai --vars '{\"user_query\": \"Take me to google.com\", \"available_intents\": [{\"name\": \"navigate\", \"description\": \"Go to URL\"}]}'\n\n# Validate PAL files\npal validate prompts/ --recursive\n\n# Run evaluation tests\npal evaluate evaluation/classify_intent.eval.yaml\n```\n\n### 4. Use Programmatically\n\n```python\nimport asyncio\nfrom pal import PromptCompiler, PromptExecutor, MockLLMClient\n\nasync def main():\n # Set up components\n compiler = PromptCompiler()\n llm_client = MockLLMClient(\"Mock response\")\n executor = PromptExecutor(llm_client)\n\n # Compile prompt\n variables = {\n \"user_query\": \"What's the weather?\",\n \"available_intents\": [{\"name\": \"search\", \"description\": \"Search for info\"}]\n }\n\n compiled_prompt = await compiler.compile_from_file(\n \"prompts/classify_intent.pal\",\n variables\n )\n\n print(\"Compiled Prompt:\", compiled_prompt)\n\nasyncio.run(main())\n```\n\n## \ud83e\uddea Evaluation System\n\nCreate test suites to validate your prompts:\n\n```yaml\n# evaluation/classify_intent.eval.yaml\npal_version: \"1.0\"\nprompt_id: \"classify-user-intent\"\ntarget_version: \"1.0.0\"\n\ntest_cases:\n - name: \"navigation_test\"\n variables:\n user_query: \"Go to google.com\"\n available_intents: [{ \"name\": \"navigate\", \"description\": \"Visit URL\" }]\n assertions:\n - type: \"json_valid\"\n - type: \"contains\"\n config:\n text: \"navigate\"\n```\n\n## \ud83c\udfd7\ufe0f Architecture\n\nPAL follows modern software engineering principles:\n\n- **Schema Validation**: All files are validated against strict Pydantic schemas\n- **Dependency Resolution**: Automatic import resolution with circular dependency detection\n- **Template Engine**: Jinja2 for powerful variable interpolation and logic\n- **Observability**: Structured logging with execution metrics and cost tracking\n- **Type Safety**: Full type hints and runtime validation\n\n## \ud83d\udee0\ufe0f CLI Commands\n\n| Command | Description |\n| -------------- | ------------------------------------------------- |\n| `pal compile` | Compile a PAL file into a prompt string |\n| `pal execute` | Compile and execute a prompt with an LLM |\n| `pal validate` | Validate PAL files for syntax and semantic errors |\n| `pal evaluate` | Run evaluation tests against prompts |\n| `pal info` | Show detailed information about PAL files |\n\n## \ud83e\udde9 Component Types\n\nPAL supports different types of reusable components:\n\n- **persona**: AI personality and role definitions\n- **task**: Specific instructions or objectives\n- **context**: Background information and knowledge\n- **rules**: Constraints and guidelines\n- **examples**: Few-shot learning examples\n- **output_schema**: Output format specifications\n- **reasoning**: Thinking strategies and methodologies\n- **trait**: Behavioral characteristics\n- **note**: Documentation and comments\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83c\udd98 Support\n\n- \ud83d\udcda [Documentation](https://prompt-assembly-language-pal.readthedocs.io)\n- \ud83d\udc1b [Issues](https://github.com/cyqlelabs/pal/issues)\n- \ud83d\udcac [Discussions](https://github.com/cyqlelabs/pal/discussions)\n\n## \ud83d\uddfa\ufe0f Roadmap\n\n- [ ] **PAL Registry**: Centralized repository for sharing components\n- [ ] **Visual Builder**: Drag-and-drop prompt composition interface\n- [ ] **IDE Extensions**: VS Code and other editor integrations\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 Nicol\u00e1s Iglesias <nfiglesias@gmail.com>\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "Prompt Assembly Language - A framework for managing LLM prompts as versioned, composable software artifacts",
"version": "0.0.4",
"project_urls": {
"Documentation": "https://pal-framework.readthedocs.io",
"Homepage": "https://github.com/cyqlelabs/pal",
"Issues": "https://github.com/cyqlelabs/pal/issues",
"Repository": "https://github.com/cyqlelabs/pal"
},
"split_keywords": [
"ai",
" claude",
" gpt",
" llm",
" prompt-engineering",
" prompts"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "7239b4a195b08c89a6945dddd539ae1ad1e3a67290bc2138e76711efefa30785",
"md5": "c332591fbf5973679ce18db549a2e819",
"sha256": "d0a77b17e53d05c77257b64cb3a14d7a3bde268d4f77247321eb21e74c348f56"
},
"downloads": -1,
"filename": "pal_framework-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c332591fbf5973679ce18db549a2e819",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 32407,
"upload_time": "2025-08-13T15:36:59",
"upload_time_iso_8601": "2025-08-13T15:36:59.178141Z",
"url": "https://files.pythonhosted.org/packages/72/39/b4a195b08c89a6945dddd539ae1ad1e3a67290bc2138e76711efefa30785/pal_framework-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "72575fa76a940d5cbd06e83f9791b28b8ee16f7f948776bd8e2ad38c03f75ae8",
"md5": "95889413e9b49548536eff7b744921c0",
"sha256": "01057727ddcac4e87d3b2c378782a7efdfb3ddbcc8daefd8769feb469c4c77cd"
},
"downloads": -1,
"filename": "pal_framework-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "95889413e9b49548536eff7b744921c0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 153895,
"upload_time": "2025-08-13T15:37:00",
"upload_time_iso_8601": "2025-08-13T15:37:00.619582Z",
"url": "https://files.pythonhosted.org/packages/72/57/5fa76a940d5cbd06e83f9791b28b8ee16f7f948776bd8e2ad38c03f75ae8/pal_framework-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-13 15:37:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cyqlelabs",
"github_project": "pal",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pal-framework"
}