Frontmatter#

class langchain_prompty.core.Frontmatter[source]#

Class for reading frontmatter from a string or file.

Methods

__init__()

read(string)

Returns dict with separated frontmatter from string.

read_file(path)

Reads file at path and returns dict with separated frontmatter.

__init__()#
classmethod read(string: str) dict[str, Any][source]#

Returns dict with separated frontmatter from string.

Returned dict keys: attributes – extracted YAML attributes in dict form. body – string contents below the YAML separators frontmatter – string representation of YAML

Parameters:

string (str)

Return type:

dict[str, Any]

classmethod read_file(path: str) dict[str, Any][source]#

Reads file at path and returns dict with separated frontmatter. See read() for more info on dict return value.

Parameters:

path (str)

Return type:

dict[str, Any]