Skip to content

Add Markdown Prompting Protocol for Langfun#627

Open
copybara-service[bot] wants to merge 1 commit intomainfrom
test_833461586
Open

Add Markdown Prompting Protocol for Langfun#627
copybara-service[bot] wants to merge 1 commit intomainfrom
test_833461586

Conversation

@copybara-service
Copy link

Add Markdown Prompting Protocol for Langfun

Introduces MarkdownPromptingProtocol to enable LLMs to generate structured outputs using markdown format instead of Python code.

Key Changes:

  • New markdown.py with protocol implementation supporting all PyGlove types (primitives, Objects, Lists, Unions)
  • Uses ```pyobject code blocks for structured Python objects
  • Robust parsing handles nested objects and LLM-generated formatting quirks
  • Test suite in markdown_test.py
  • Registers as protocol='markdown' in lf.query() calls

Benefits:

  • More natural format for LLMs, reducing syntax errors
  • Better alignment with LLM training data
  • Maintains full type safety

Introduces MarkdownPromptingProtocol to enable LLMs to generate structured outputs using markdown format instead of Python code.

Key Changes:

* New `markdown.py` with protocol implementation supporting all PyGlove types (primitives, Objects, Lists, Unions)
* Uses ```pyobject code blocks for structured Python objects
* Robust parsing handles nested objects and LLM-generated formatting quirks
* Test suite in markdown_test.py
* Registers as `protocol='markdown'` in `lf.query()` calls

Benefits:
* More natural format for LLMs, reducing syntax errors
* Better alignment with LLM training data
* Maintains full type safety
PiperOrigin-RevId: 833461586
@google-cla
Copy link

google-cla bot commented Nov 19, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants