A Python interpreter for AIML 2.0 (Artificial Intelligence Markup Language), supporting advanced features from the ALICE/Pandora AIML sets.
- AIML 2.0 support: Handles most tags used in ALICE2 and Pandora AIML files.
- Pattern matching: Supports wildcards, sets, and placeholders.
- Template processing: Handles tags like
<set>,<get>,<think>,<srai>,<star>,<map>,<random>,<li>,<condition>,<person>,<formal>,<lowercase>,<uppercase>,<bot>,<what>,<round>, and more. - Map and set files: Loads
.mapand.setfiles for use in AIML templates. - Properties: Loads
.propertiesfiles for bot and global variables. - Safe no-ops: Ignores or logs warnings for unsupported tags like
<learn>,<loop>, and<sraix>. - Extensible: Designed for use as both a library and a CLI.
<sraix>,<learn>, and<loop>are no-ops (log a warning, do not perform external calls or dynamic learning).- No support for custom predicates, user sessions, or persistent storage out of the box.
- No web or GUI interface (CLI and library only).
Clone the repository and install dependencies:
git clone ...
cd pyaiml2
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtfrom pyaiml2.interpreter import AIMLInterpreter
interpreter = AIMLInterpreter()
interpreter.load('/path/to/aiml_and_map_files')
response = interpreter.respond('WHAT IS THE CAPITAL OF TEXAS')
print(response) # e.g., 'Austin'python -m pyaiml2.cli /path/to/aiml_and_map_files
> WHAT IS THE CAPITAL OF TEXAS
Austin<set>,<get>,<think>,<srai>,<star>,<map>,<random>,<li>,<condition>,<person>,<formal>,<lowercase>,<uppercase>,<bot>,<what>,<round>,<name>(as child),<template>,<category>,<aiml>,<eval>(as a no-op)- Safe no-ops:
<learn>,<loop>,<sraix>
<category>
<pattern>CAPITAL OF TEXAS</pattern>
<template><map name="state2capital">texas</map></template>
</category>
<category>
<pattern>GIVE ME A FRUIT</pattern>
<template><random><li>Apple</li><li>Banana</li><li>Cherry</li></random></template>
</category>
<category>
<pattern>TEST CONDITION</pattern>
<template><condition name="myvar">
<li value="foo">You chose foo.</li>
<li value="bar">You chose bar.</li>
<li>Default branch.</li>
</condition></template>
</category>Run the test suite with:
source .venv/bin/activate
pytest -v pyaiml2/test_interpreter.pyThis project is based on ALICE/Pandora AIML and is released under the GNU Lesser General Public License (LGPL).