forked from ahmadfaizalbh/Chatbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKG-INFO
323 lines (238 loc) · 9.67 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
Metadata-Version: 1.0
Name: chatbotAI
Version: 0.2.0.1
Summary: A chatbot AI engine is a chatbot builder platform that provids both bot intelligence and chat handler with minimal codding
Home-page: https://github.com/ahmadfaizalbh/Chatbot
Author: Ahmad Faizal B H
Author-email: ahmadfaizalbh726@gmail.com
License: MIT
Description-Content-Type: UNKNOWN
Description: Chatbot
=======
Python chatbot AI that helps in creating a python based chatbot with
minimal coding. This provides both bots AI and chat handler and also
allows easy integration of REST API's and python function calls which
makes it unique and more powerful in functionality. This AI provides
numerous features like learn, memory, conditional switch, topic-based
conversation handling, etc.
Installation
------------
Install from PyPI:
.. code:: sh
pip install chatbotAI
install from github:
.. code:: sh
git clone https://github.com/ahmadfaizalbh/Chatbot.git
cd Chatbot
python setup.py install
Sample Code (with wikipedia search API integration)
---------------------------------------------------
.. code:: python
from chatbot import Chat,reflections,multiFunctionCall
import wikipedia
def whoIs(query,session_id="general"):
try:
return wikipedia.summary(query)
except:
for newquery in wikipedia.search(query):
try:
return wikipedia.summary(newquery)
except:
pass
return "I don't know about "+query
call = multiFunctionCall({"whoIs":whoIs})
first_question="Hi, how are you?"
Chat("examples/Example.template", reflections,call=call).converse(first_question)
For Detail on how to build Facebook messenger bot checkout `Facebook
Integration.ipynb <https://github.com/ahmadfaizalbh/Meetup-Resources/blob/master/Facebook%20Integration.ipynb>`__
For Jupyter notebook Chatbot checkout `Infobot built using
NLTK-Chatbot <https://github.com/ahmadfaizalbh/Meetup-Resources/blob/master/How%20to%20build%20a%20bot.ipynb>`__
Sample Apps
^^^^^^^^^^^
1. A sample facebook messenger bot built using
`messengerbot <https://github.com/geeknam/messengerbot/pulls>`__,
`Django <https://github.com/django/django>`__ and
`NLTK-Chatbot <#chatbot>`__ is available here `Facebook messenger
bot <https://github.com/ahmadfaizalbh/FacebookMessengerBot/>`__
2. A sample microsoft bot built using `Microsoft Bot Connector Rest API
-
v3.0 <https://docs.botframework.com/en-us/restapi/connector/#navtitle>`__,
`Django <https://github.com/django/django>`__ and
`NLTK-Chatbot <#chatbot>`__ is available here `Micosoft
Chatbot <https://github.com/ahmadfaizalbh/Microsoft-chatbot/>`__
List of feature supported in bot template
-----------------------------------------
1. `Memory <#memory>`__
2. `Get matched group <#get-matched-group>`__
3. `Recursion <#recursion>`__
4. `Condition <#condition>`__
5. `Change Topic <#change-topic>`__
6. `Interact with python function <#interact-with-python-function>`__
7. `REST API integration <#rest-api-integration>`__
8. `Topic based group <#topic-based-group>`__
9. `Learn <#learn>`__
10. `To upper case <#to-upper-case>`__
11. `To lower case <#to-lower-case>`__
12. `Capitalize <#capitalize>`__
13. `Previous <#previous>`__
--------------
Memory
------
Set Memory
^^^^^^^^^^
.. code:: sh
{ variable : value }
In think mode
.. code:: sh
{! variable : value }
Get Memory
^^^^^^^^^^
.. code:: sh
{ variable }
Get matched group
-----------------
Get Nth matched group of client pattern
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: sh
%N
Example to get first matched
.. code:: sh
%1
Get Nth matched group of bots pattern
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: sh
%!N
Example to get first matched
.. code:: sh
%!1
Recursion
---------
Get response as if client said this new statement
.. code:: sh
{% chat statement %}
It will do a pattern match for statement
Condition
---------
::
{% if condition %}
do this first
{% elif condition %}
do this next
{% else %}
do otherwise
{% endif %}
Change Topic
------------
.. code:: sh
{% topic TopicName %}
Interact with python function
-----------------------------
.. code:: sh
{% call functionName: value %}
REST API integration
--------------------
In API.json file
^^^^^^^^^^^^^^^^
.. code:: sh
{
"APIName":{
"auth" : {
"url":"https://your_rest_api_url/login.json",
"method":"POST",
"data":{
"user":"Your_Username",
"password":"Your_Password"
}
},
"MethodName" : {
"url":"https://your_rest_api_url/GET_method_Example.json",
"method":"GET",
"params":{
"key1":"value1",
"key2":"value2",
...
},
"value_getter":[order in which data has to be picked from json response]
},
"MethodName1" : {
"url":"https://your_rest_api_url/GET_method_Example.json",
"method":"POST",
"data":{
"key1":"value1",
"key2":"value2",
...
},
"value_getter":[order in which data has to be picked from json response]
},
"MethodName2" : {
...
},
...
},
"APIName2":{
...
},
...
}
*If authentication is required only then ``auth`` method is needed.The
``data`` and ``params`` defined in pi.json file acts as defult values
and all key value pair defined in template file overrides the default
value.\ ``value_getter`` consistes of list of keys in order using which
info from json will be collected.*
In Template file
^^^^^^^^^^^^^^^^
.. code:: sh
[ APIName:MethodName,Key1:value1 (,Key*:value*) ]
you can have any number of key value pair and all key value pair will
override data or params depending on ``method``, if ``method`` is
``POST`` then it overrides data and if method is ``GET`` then it
overrides ``params``.
Topic based group
-----------------
.. code:: sh
{% group topicName %}
{% block %}
{% client %}client says {% endclient %}
{% response %}response text{% endresponse %}
{% endblock %}
...
{% endgroup %}
Learn
-----
.. code:: sh
{% learn %}
{% group topicName %}
{% block %}
{% client %}client says {% endclient %}
{% response %}response text{% endresponse %}
{% endblock %}
...
{% endgroup %}
...
{% endlearn %}
To upper case
-------------
.. code:: sh
{% up string %}
To lower case
-------------
.. code:: sh
{% low string %}
Capitalize
----------
.. code:: sh
{% cap string %}
Previous
--------
.. code:: sh
{% block %}
{% client %}client's statement pattern{% endclient %}
{% prev %}previous bot's statement pattern{% endprev %}
{% response %}response string{% endresponse %}
{% endblock %}
Keywords: chatbot ai engine and chat builder platform
Platform: Windows
Platform: Linux
Platform: Solaris
Platform: Mac OS-X
Platform: Unix