https://github.com/zanzythebar/poml-go
Pure Go implementation of Microsofts PoML library
https://github.com/zanzythebar/poml-go
ai go golang llm microsoft poml prompt-engineering
Last synced: 17 days ago
JSON representation
Pure Go implementation of Microsofts PoML library
- Host: GitHub
- URL: https://github.com/zanzythebar/poml-go
- Owner: ZanzyTHEbar
- License: mit
- Created: 2025-09-20T17:52:43.000Z (20 days ago)
- Default Branch: main
- Last Pushed: 2025-09-20T17:53:53.000Z (20 days ago)
- Last Synced: 2025-09-20T19:29:59.199Z (20 days ago)
- Topics: ai, go, golang, llm, microsoft, poml, prompt-engineering
- Language: Go
- Homepage:
- Size: 3.13 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# POML: Prompt Orchestration Markup Language
[](https://pkg.go.dev/github.com/microsoft/poml/go/sdk)
[](https://goreportcard.com/report/github.com/microsoft/poml)
[](https://opensource.org/licenses/MIT)**POML (Prompt Orchestration Markup Language)** is a novel markup language designed to bring structure, maintainability, and versatility to advanced prompt engineering for Large Language Models (LLMs). It addresses common challenges in prompt development, such as lack of structure, complex data integration, format sensitivity, and inadequate tooling. POML provides a systematic way to organize prompt components, integrate diverse data types seamlessly, and manage presentation variations, empowering developers to create more sophisticated and reliable LLM applications.
## Demo Video
[](https://youtu.be/b9WDcFsKixo)
## Key Features
* **Structured Prompting Markup**: Employs an HTML-like syntax with semantic components such as ``, ``, and `` to encourage modular design, enhancing prompt readability, reusability, and maintainability.
* **Comprehensive Data Handling**: Incorporates specialized data components (e.g., ``, ``, ``) that seamlessly embed or reference external data sources like text files, spreadsheets, and images, with customizable formatting options.
* **Decoupled Presentation Styling**: Features a CSS-like styling system that separates content from presentation. This allows developers to modify styling (e.g., verbosity, syntax format) via `` definitions or inline attributes without altering core prompt logic, mitigating LLM format sensitivity.
* **Integrated Templating Engine**: Includes a built-in templating engine with support for variables (`{{ }}`), loops (`for`), conditionals (`if`), and variable definitions (``) for dynamically generating complex, data-driven prompts.
* **Rich Development Toolkit**:
* **Go SDK**: Complete Go implementation with comprehensive APIs for parsing, rendering, and manipulating POML documents.
* **Command Line Interface**: Built-in CLI tools for quick parsing, validation, and rendering of POML files.## ๐ Advanced Features (Latest Release)
### Speaker Mode Implementation ๐ญ
POML now supports **conversation structure** with automatic speaker assignment:```xml
You are a helpful AI assistant with multimedia capabilities.
Please analyze this document and create a summary.
I've processed the document and created the requested summary.
```
**Benefits:**
- Automatic speaker detection and assignment
- Structured conversation output
- Compatible with chat-based LLMs
- Enhanced conversation flow management### Multimedia Content Support ๐ผ๏ธ
Embed images and other media directly in your prompts:```xml
Here's an example image:
![]()
Or embed base64 content:
![]()
```
**Features:**
- Base64 encoding for embedded content
- MIME type detection and validation
- Alt text support for accessibility
- Rich content arrays for mixed media### Advanced Expression Engine โก
Complex template expressions with method chaining:```xml
Document stats: {{content.length}} characters
Preview: {{content.substring(0, 100)}}...
Formatted: {{content.replace(/\n/g, ' ').trimStart().toUpper()}}
Processing {{item}}: {{loop.index + 1}} of {{loop.total}}
```
**Capabilities:**
- String manipulation methods (`replace`, `substring`, `toUpper`, `trimStart`)
- Regular expression support with flags (`/\n/g`)
- Method chaining for complex transformations
- Loop variables (`loop.index`, `loop.total`)### Enhanced Error Handling ๐ก๏ธ
Robust error handling with graceful degradation:```xml
Content: {{content}}
Result: {{invalid.expression || "fallback value"}}
```
**Features:**
- Placeholder data for missing resources
- Expression evaluation error recovery
- Detailed error messages for debugging
- Production-ready reliability### Performance & Implementation Status ๐
| Implementation | Simple Parsing | Medium Complexity | Speaker Mode | Multimedia | Status |
| ------------------- | -------------- | ----------------- | -------------- | -------------- | ---------------------- |
| **Go (Production)** | ~200ยตs | ~400ยตs | โ Full Support | โ Full Support | ๐ข **PRODUCTION READY** |**Performance Benchmarks:**
- **Sub-millisecond execution** for typical use cases
- **Linear scalability** with document complexity
- **Robust error handling** with graceful degradation
- **Production-ready reliability** with comprehensive testing**Implementation Highlights:**
- โ **Speaker Mode**: Automatic conversation structure with role assignment
- โ **Multimedia Support**: Base64 encoding, MIME detection, rich content arrays
- โ **Advanced Expressions**: Method chaining, regex support, complex transformations
- โ **Template Engine**: Variables, loops, conditionals with error recovery
- โ **Production Ready**: High-performance Go implementation optimized for enterprise use## Quick Start
Here's a very simple POML example. Please put it in a file named `example.poml`. Make sure it resides in the same directory as the `photosynthesis_diagram.png` image file.
```xml
You are a patient teacher explaining concepts to a 10-year-old.
Explain the concept of photosynthesis using the provided image as a reference.
Keep the explanation simple, engaging, and under 100 words.
Start with "Hey there, future scientist!".
```
This example defines a role and task for the LLM, includes an image for context, and specifies the desired output format. With the POML toolkit, the prompt can be easily rendered with a flexible format, and tested with a vision LLM.
## Installation
### Go Module
Add POML to your Go project:
```bash
go get github.com/microsoft/poml/go/sdk
```### CLI Tool
Install the command-line interface:
```bash
go install github.com/microsoft/poml/go/cmd/pomlcli@latest
```### Building from Source
Clone the repository and build:
```bash
git clone https://github.com/microsoft/poml.git
cd poml/go
go build ./cmd/pomlcli
```## Documentation
For detailed information on POML syntax, components, styling, and templating, please refer to our [documentation](docs/index.md).
## Learn More
* **Watch our Demo Video on YouTube:** [POML Introduction & Demo](https://youtu.be/b9WDcFsKixo)
* **Join our Discord community:** Connect with the team and other users on our [Discord server](https://discord.gg/FhMCqWzAn6).
* **Read the Research Paper (coming soon):** For an in-depth understanding of POML's design, implementation, and evaluation, check out our paper: [Paper link TBD](TBD).## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
## Responsible AI
This project has been evaluated and certified to comply with the Microsoft Responsible AI Standard. The team will continue to monitor and maintain the repository, addressing any severe issues, including potential harms, if they arise. For more details, refer to the [Responsible AI Readme](RAI_README.md).
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.