-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Y-Bot has a number of examples added, with full AIML and Python <exte…
…nsion>'s to support external data retrieval and storage
- Loading branch information
Showing
14 changed files
with
222 additions
and
40 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
Copyright (c) 2016 Keith Sterling | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, | ||
and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions | ||
of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO | ||
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
""" | ||
|
||
""" | ||
This is an example extension that allow syou to call an external service to retreive the bank balance | ||
of the customer. Currently contains no authentication | ||
""" | ||
import logging | ||
|
||
class BankingBalanceExtension(object): | ||
|
||
# execute() is the interface that is called from the <extension> tag in the AIML | ||
def execute(self, data): | ||
logging.debug ("Bank Balance - Calling external service for with extra data [%s]"%(data)) | ||
|
||
# | ||
# Add the logic to receive the balance and format it into pounds and pence and either CREDIT|DEBIT | ||
# | ||
# | ||
|
||
return "0 00 CREDIT" |
File renamed without changes.
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,35 @@ | ||
""" | ||
Copyright (c) 2016 Keith Sterling | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, | ||
and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions | ||
of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO | ||
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
""" | ||
|
||
""" | ||
This is an example extension that allow you to call an external service to retreive the energy consumption data | ||
of the customer. Currently contains no authentication | ||
""" | ||
import logging | ||
|
||
class EnergyUsageExtension(object): | ||
|
||
# execute() is the interface that is called from the <extension> tag in the AIML | ||
def execute(self, data): | ||
logging.debug ("Energy Usage - Calling external service for with extra data [%s]"%(data)) | ||
|
||
# | ||
# Add the logic to receive the balance and format it into KWh for Gas and Electricity consumption | ||
# | ||
# | ||
|
||
return "0 0 KWh" |
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,35 @@ | ||
""" | ||
Copyright (c) 2016 Keith Sterling | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, | ||
and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions | ||
of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO | ||
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
""" | ||
|
||
""" | ||
This is an example extension that allow syou to call an external service to retreive the bank balance | ||
of the customer. Currently contains no authentication | ||
""" | ||
import logging | ||
|
||
class BankingBalanceExtension(object): | ||
|
||
# execute() is the interface that is called from the <extension> tag in the AIML | ||
def execute(self, data): | ||
logging.debug ("Bank Balance - Calling external service for with extra data [%s]"%(data)) | ||
|
||
# | ||
# Add the logic to receive the balance and format it into pounds and pence and either CREDIT|DEBIT | ||
# | ||
# | ||
|
||
return "0 00 CREDIT" |
Empty file.
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,25 @@ | ||
import unittest | ||
import os | ||
from test.aiml_tests.client import TestClient | ||
from programy.config.brain import BrainFileConfiguration | ||
|
||
|
||
class BankBalanceTestsClient(TestClient): | ||
|
||
def __init__(self): | ||
TestClient.__init__(self, debug=True) | ||
|
||
def load_configuration(self, arguments): | ||
super(BankBalanceTestsClient, self).load_configuration(arguments) | ||
self.configuration.brain_configuration._aiml_files = BrainFileConfiguration(os.path.dirname(__file__)+"/../../../../aiml/extensions/banking", ".aiml", False) | ||
|
||
class BankBalanceAIMLTests(unittest.TestCase): | ||
|
||
def setUp (self): | ||
BankBalanceAIMLTests.test_client = BankBalanceTestsClient() | ||
|
||
def test_balance(self): | ||
response = BankBalanceAIMLTests.test_client.bot.ask_question("testif", "WHAT IS MY BANK BALANCE") | ||
self.assertIsNotNone(response) | ||
self.assertEqual(response, 'Your bank balance is currently £0.00.') | ||
|
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,14 @@ | ||
import unittest | ||
|
||
from extensions.banking.balance import BankingBalanceExtension | ||
|
||
class BankBalanceExtensionTests(unittest.TestCase): | ||
|
||
def test_balance(self): | ||
|
||
balance = BankingBalanceExtension() | ||
self.assertIsNotNone(balance) | ||
|
||
result = balance.execute("NOW") | ||
self.assertIsNotNone(result) | ||
self.assertEqual("0.00", result) |
Empty file.
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,25 @@ | ||
import unittest | ||
import os | ||
from test.aiml_tests.client import TestClient | ||
from programy.config.brain import BrainFileConfiguration | ||
|
||
|
||
class TelecomsMinutesTestsClient(TestClient): | ||
|
||
def __init__(self): | ||
TestClient.__init__(self, debug=True) | ||
|
||
def load_configuration(self, arguments): | ||
super(TelecomsMinutesTestsClient, self).load_configuration(arguments) | ||
self.configuration.brain_configuration._aiml_files = BrainFileConfiguration(os.path.dirname(__file__)+"/../../../../aiml/extensions/telecoms", ".aiml", False) | ||
|
||
class TelecomsMinutesAIMLTests(unittest.TestCase): | ||
|
||
def setUp (self): | ||
TelecomsMinutesAIMLTests.test_client = TelecomsMinutesTestsClient() | ||
|
||
def test_balance(self): | ||
response = TelecomsMinutesAIMLTests.test_client.bot.ask_question("testif", "HOW MANY MINUTES DO I HAVE LEFT") | ||
self.assertIsNotNone(response) | ||
self.assertEqual(response, 'This month you have 0 minutes available and have consumed 0 minutes.') | ||
|
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,14 @@ | ||
import unittest | ||
|
||
from extensions.telecoms.minutes import TelecomMinutesExtension | ||
|
||
class BankBalanceExtensionTests(unittest.TestCase): | ||
|
||
def test_balance(self): | ||
|
||
minutes = TelecomMinutesExtension() | ||
self.assertIsNotNone(minutes) | ||
|
||
result = minutes.execute("NOW") | ||
self.assertIsNotNone(result) | ||
self.assertEqual("0 0", result) |
Empty file.
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,25 @@ | ||
import unittest | ||
import os | ||
from test.aiml_tests.client import TestClient | ||
from programy.config.brain import BrainFileConfiguration | ||
|
||
|
||
class BankBalanceTestsClient(TestClient): | ||
|
||
def __init__(self): | ||
TestClient.__init__(self, debug=True) | ||
|
||
def load_configuration(self, arguments): | ||
super(BankBalanceTestsClient, self).load_configuration(arguments) | ||
self.configuration.brain_configuration._aiml_files = BrainFileConfiguration(os.path.dirname(__file__)+"/../../../../aiml/extensions/banking", ".aiml", False) | ||
|
||
class BankBalanceAIMLTests(unittest.TestCase): | ||
|
||
def setUp (self): | ||
BankBalanceAIMLTests.test_client = BankBalanceTestsClient() | ||
|
||
def test_balance(self): | ||
response = BankBalanceAIMLTests.test_client.bot.ask_question("testif", "WHAT IS MY BANK BALANCE") | ||
self.assertIsNotNone(response) | ||
self.assertEqual(response, 'Your bank balance is currently £0.00.') | ||
|
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,14 @@ | ||
import unittest | ||
|
||
from extensions.banking.balance import BankingBalanceExtension | ||
|
||
class BankBalanceExtensionTests(unittest.TestCase): | ||
|
||
def test_balance(self): | ||
|
||
balance = BankingBalanceExtension() | ||
self.assertIsNotNone(balance) | ||
|
||
result = balance.execute("NOW") | ||
self.assertIsNotNone(result) | ||
self.assertEqual("0.00", result) |