eleanor.llm.interop
Language model canonical interoperability module
Attributes
env
module-attribute
env = Environment(
loader=PackageLoader(
package_name="eleanor.llm.interop",
package_path="templates",
encoding="utf-8",
),
trim_blocks=True,
lstrip_blocks=True,
autoescape=False,
)
Classes
CanonicalStringParseError
Bases: Exception
Raised when a string cannot be parsed into a canonical format
CanonicalTemplateError
Bases: Exception
Raised in a Jinja template when it cannot rendered a canonical to string format
Functions
jinja_add_name
Adds the name to the beginning of the message if it doesn’t already exist.
The intended use case is from within a jinja template if we need to add the name to the actual message content, we need to trigger some logic so that it isn’t added twice.
Parameters:
-
name
(str
) –The name to be added.
-
message
(str
) –The message to which the name will be added.
Returns:
-
str
(str
) –The modified message with the name added.
jinja_raise_exception
Raises a ValueError with the given message.
Intended use is to enable raising of exceptions with custom messages from within a jinja template.
Parameters:
-
message
(str
) –The error message to be raised.
Raises:
-
ValueError
–The exception with the given message.
jinja_safe_chatml
Jinja filter that removes ChatML tags from the input
Parameters:
-
s
(str
) –The input string containing ChatML tags.
Returns:
-
str
(str
) –The input string with ChatML tags removed and stripped.
jinja_safe_cr
Jinja filter that removes CommanderR/CommanderR+ tags from the input
Parameters:
-
s
(str
) –The input string containing chatml tags.
Returns:
-
str
(str
) –The input string with chatml tags removed and stripped.
jinja_safe_llama3
Jinja filter that removes Llama3 tags from the input
Parameters:
-
s
(str
) –The input string containing ChatML tags.
Returns:
-
str
(str
) –The input string with ChatML tags removed and stripped.