Эх сурвалжийг харах

add doc for neurotransmitter

nico 8 жил өмнө
parent
commit
9059f76feb

+ 1 - 0
Docs/neuron_list.md

@@ -7,6 +7,7 @@ A neuron is a module you can use in your synapses. See the [complete neuron docu
 | [ansible_task](../neurons/ansible_task/)           | Run an ansible playbook                                                                 | ansible_task      |
 | [gmail_checker](../neurons/gmail_checker/)         | Get the number of unread email and their subjects from a gmail account                  | gmail_checker     |
 | [kill_switch](../neurons/kill_switch/)             | Stop Jarvis process                                                                     | kill_switch       |
+| [neurotransmitter](../neurons/neurotransmitter/)   | Link synapses together                                                                  | neurotransmitter  |
 | [push_message](../neurons/push_message/)           | Send a push message to a remote device like Android/iOS/Windows Phone or Chrome browser | push_message      |
 | [say](../neurons/say/)                             | Make Jarvis talk by using TTS                                                           | say               |
 | [script](../neurons/script/)                       | Run an executable script                                                                | script            |

+ 67 - 0
neurons/neurotransmitter/README.md

@@ -0,0 +1,67 @@
+# neurotransmitter
+
+## Synopsis
+
+Link synapses together. Call a synapse from another one depending on the captured speech from the user.
+
+## Options
+
+| parameter | required | default | choices | comment                                                                                        |
+|-----------|----------|---------|---------|------------------------------------------------------------------------------------------------|
+| links     | yes      |         |         | List of tuple synapse/answer object                                                            |
+| synapse   | yes      |         |         | Name of the synapse to launch if the captured audio from the STT is present in the answer list |
+| answers   | yes      |         |         | List of sentences that are valid for running the attached synapse                              |
+| default   | yes      |         |         | Name of the synapse to launch if the captured audio doesn't match any answers                  |
+
+## Return Values
+
+None
+
+## Synapses example
+
+Here the synapse will ask the user if he likes french fries. If the user answer "yes" or "maybe", he will be redirected to the synapse2 that say something.
+If the user answer no, he will be redirected to another synapse that say something else.
+If the user say something that is not present in `answers`, he will be redirected to the synapse4.
+
+```
+ - name: "synapse1"
+    neurons:
+      - say:
+          message: "do you like french fries?"
+      - neurotransmitter:
+          links:
+            - synapse: "synapse2"
+              answers:
+                - "absolutely"
+                - "maybe"
+            - synapse: "synapse3"
+              answers:
+                - "no at all"
+          default: "synapse4"
+    signals:
+      - order: "ask me a question"
+
+  - name: "synapse2"
+    neurons:
+      - say:
+          message: "You like french fries!! Me too! I suppose..."
+    signals:
+      - order: "synapse2"
+
+  - name: "synapse3"
+    neurons:
+      - say:
+          message: "You don't like french fries. It's ok."
+    signals:
+      - order: "synapse3"
+      
+  - name: "synapse4"
+    neurons:
+      - say:
+          message: "I havn't understood your answer"
+    signals:
+      - order: "synapse4"
+```
+
+
+

+ 3 - 1
test.py

@@ -23,9 +23,11 @@ logger.setLevel(logging.DEBUG)
 
 SettingLoader.get_settings()
 
+brain = BrainLoader.get_brain()
+
 order = "pose moi une question"
 # order = "synapse2"
-oa = OrderAnalyser(order=order)
+oa = OrderAnalyser(order=order, brain=brain)
 
 oa.start()