character-ai / prompt-poet

Streamlines and simplifies prompt design for both developers and non-technical users with a low code approach.
https://pypi.org/project/prompt-poet/
MIT License
907 stars 73 forks source link

yaml.scanner.ScannerError: while scanning a simple key #20

Open MotzWanted opened 2 months ago

MotzWanted commented 2 months ago
yaml.scanner.ScannerError: while scanning a simple key
  in "<unicode string>", line 39, column 1
could not find expected ':'
  in "<unicode string>", line 41, column 11

The error indicates that the YAML parser is having trouble understanding the structure of my prompt due to an issue with a colon (:) in the prompt?

tokestermw commented 2 months ago

Looks like multiline variables don't work

from prompt_poet import Prompt

raw_template = """
- name: system instructions
  role: system
  content: |
    Your name is {{ long_character_name }} and you are meant to be helpful and never harmful to humans.
"""

template_data = {
  "long_character_name": "Character\nAssistant",
}

prompt = Prompt(
    raw_template=raw_template,
    template_data=template_data
)
0xmihutao commented 2 months ago

use {{ escape_special_characters(long_character_name) }}

See the example here: https://github.com/character-ai/prompt-poet/blob/main/prompt_poet/examples/sections/cai_message_pins.yml.j2#L20

DoiiarX commented 2 months ago

escape_special_characters

where is the define of escape_special_characters?