poml icon indicating copy to clipboard operation
poml copied to clipboard

JSON formats in the output schema

Open durairaj-panneerselvam-agilysys opened this issue 3 months ago • 1 comments

Hi team 👋, I’m running into a problem when trying to define an output schema in JSON format inside a POML file and use it with LangchainPomlTemplate.

POML FILE

<poml>
  <system-msg>Extract the event information.</system-msg>
  <human-msg>Alice and Bob are going to a science fair on Friday.</human-msg>
  <output-schema>
    z.object({
      name: z.string(),
      date: z.string(),
      participants: z.array(z.string()),
    });
  </output-schema>
</poml>

Python code

from poml.integration.langchain import LangchainPomlTemplate

prompt = LangchainPomlTemplate.from_file("prompt_new.poml")

What happened

When I run this, I get the following error:

Input to LangchainPomlTemplate is missing variables {'\n  name'}.  
Expected: ['\n  name']  
Received: ['user_input', 'history']  
Note: if you intended {\n  name} to be part of the string and not a variable, please escape it with double curly braces like: '{{\n  name}}'.

What I Expected

The schema in should be treated as plain text and not parsed as template variables.

Question

Is there a recommended way to define a schema inside so it doesn’t get treated as template variables? Or should everything inside be automatically escaped?

I doubt that output schema is supported in langchainpomltemplate. Would have to test it myself.

Currently, you can define the output schema in langchain's approach and make that irrelevant to the poml file.

ultmaster avatar Sep 20 '25 06:09 ultmaster