Skip to content

helix90/pyaiml2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AIML 2.0 Interpreter

A Python interpreter for AIML 2.0 (Artificial Intelligence Markup Language), supporting advanced features from the ALICE/Pandora AIML sets.

Features

  • 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 .map and .set files for use in AIML templates.
  • Properties: Loads .properties files 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.

Limitations

  • <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).

Installation

Clone the repository and install dependencies:

git clone ...
cd pyaiml2
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Usage

As a Library

from 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'

As a CLI

python -m pyaiml2.cli /path/to/aiml_and_map_files
> WHAT IS THE CAPITAL OF TEXAS
Austin

Supported AIML Tags (Highlights)

  • <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>

Example AIML

<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>

Testing

Run the test suite with:

source .venv/bin/activate
pytest -v pyaiml2/test_interpreter.py

License

This project is based on ALICE/Pandora AIML and is released under the GNU Lesser General Public License (LGPL).

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages