-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from fractalego/new-documentation
New documentation
- Loading branch information
Showing
204 changed files
with
2,662 additions
and
1,437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### v 0.0. 70 | ||
|
||
* Added the keyword RETRIEVE to get list of relevant items from the knowledge base | ||
* On-the-spot rule generation | ||
* mapping lists onto queries |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+15 Bytes
(100%)
documentation/build/doctrees/rules_and_backtracking.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,4 @@ Examples | |
:maxdepth: 2 | ||
|
||
wafl_init | ||
chitchat | ||
rules | ||
rules_and_backtracking | ||
directory_structure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,181 +1,11 @@ | ||
Rules | ||
===== | ||
|
||
The file rules.wafl contains the rules used by the system. | ||
Each rule is in the following format | ||
Examples | ||
======== | ||
|
||
.. code-block:: text | ||
Trigger condition | ||
action 1 | ||
action 2 | ||
action 3 | ||
... | ||
Notice that the trigger condition has no indentation, while the actions are indented by any number spaces. | ||
Each action returns a true or false value. | ||
If that value is false, the rule stops executing and the next rule is triggered. | ||
A demo of the rules can be found in the repository `wafl_home <https://github.com/fractalego/wafl_home>`_. | ||
|
||
A rule ends when the next rule is encountered (a new trigger condition is found). | ||
The trigger condition can be a single fact. For example | ||
|
||
.. code-block:: text | ||
This bot's name is "computer" | ||
There are two actors in the system: "the user" and "the bot". | ||
One simple rule example can be | ||
|
||
.. code-block:: text | ||
The user asks what is this bot's name | ||
SAY Hello, my name is Computer | ||
The rule above will be triggered when the user asks what is this bot's name. | ||
There are 7 types of actions: | ||
**SAY**, | ||
**REMEMBER**, | ||
**asking a question**, | ||
**generate a text**, | ||
**triggering of another rule**, | ||
**code execution**, | ||
**entailment**. | ||
|
||
|
||
SAY command | ||
----------- | ||
|
||
This command will make the bot say something. | ||
For example the rule above will make the bot say "Hello, my name is computer". | ||
|
||
REMEMBER command | ||
---------------- | ||
|
||
This command will make the bot remember something. | ||
for example the rule below will make the bot remember the user's name. | ||
|
||
.. code-block:: text | ||
The user says their name is John | ||
REMEMBER The user's name is John | ||
Asking a question | ||
----------------- | ||
|
||
Typing a question (with or without question mark) will return a variable. | ||
This variable can be used later in the rule | ||
For example the rule below will make the bot ask the user's name. | ||
|
||
.. code-block:: text | ||
The user says their name | ||
name = what is the user's name? | ||
REMEMBER The user's name is {name} | ||
Yes/No questions return a truth condition. | ||
For example by using the rule below, the bot will ask the user if they want to remember their name. | ||
|
||
.. code-block:: text | ||
The user says their name | ||
name = what is the user's name? | ||
Do you want to remember the user's name? | ||
REMEMBER The user's name is {name} | ||
If the user says "no", the rule will stop executing and the REMEMBER command will never be used | ||
|
||
|
||
Generate a text | ||
---------------- | ||
|
||
A text can be generated in a similar fashion as when asking questions | ||
|
||
.. code-block:: text | ||
The user says their name | ||
name = what is the user's name? | ||
italian_name = the italian version of {name} is | ||
SAY The italian version of {name} is {italian_name} | ||
The text will be generated by the line "the italian version of {name}" according to the LLM model. | ||
The only difference with asking question is that the text on the right hand side of `=` is a statement | ||
and not a question. | ||
|
||
Triggering of another rule | ||
-------------------------- | ||
|
||
A rule can trigger another rule as follows | ||
|
||
.. code-block:: text | ||
The user says their name | ||
name = what is the user's name? | ||
the name if the user is {name} | ||
The name of the user is John | ||
SAY Hello John! | ||
In this case the second rule is triggered if the user says their name is John. | ||
|
||
Code execution | ||
-------------- | ||
|
||
The code execution is done by using the python syntax. | ||
A function defined in the file `functions.py` can be called from the rule. | ||
|
||
|
||
For example, the file `rules.wafl` contains the following rule | ||
|
||
.. code-block:: text | ||
The user says their name | ||
name = what is the user's name? | ||
greet({name}) | ||
and the file `functions.py` contains the following function | ||
|
||
.. code-block:: python | ||
def greet(name): | ||
print("Hello", name) | ||
When the user says their name, the bot will greet the user by calling the function greet with the user's name as argument. | ||
However print() does not activate the SAY command. | ||
From the `functions.py` file, a rule can be triggered by using the syntax `"% ... %"` | ||
|
||
.. code-block:: python | ||
def greet(name): | ||
"% SAY Hello %" | ||
f"% SAY your name is {name} %" | ||
The first line will make the bot say "Hello". The second line will make the bot say "your name is John" if the user's name is John. | ||
|
||
The syntax `"% ... %"`, can be used to trigger a rule, to generate a text, to ask a question, to remember something, or any other action available in the rules file. | ||
For example the prior function can be written as follows | ||
|
||
.. code-block:: python | ||
def greet(name): | ||
"% SAY Hello %" | ||
"% SAY your name is {name} %" | ||
date = "% what is the date today? %" | ||
"% SAY today is {date} %" | ||
while "% Do you want to continue? %": | ||
"% SAY I am happy to continue %" | ||
Entailment | ||
---------- | ||
|
||
The entailment is done by using the :- operator. if RHS entails LHS, then LSH :- RHS is true, otherwise it is false. | ||
For example the rule below will stop at the second line if the user's name is not John. | ||
|
||
.. code-block:: text | ||
The user says their name | ||
name = what is the user's name? | ||
The user's name is John :- The user's name is {name} | ||
SAY Your name is John! | ||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
writing_the_rules | ||
rules_and_backtracking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.