Skip to content

JSON formats in the output schema #172

@durairaj-panneerselvam-agilysys

Description

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions