dynamic-learning-model 1.0__tar.gz → 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dynamic-learning-model
3
- Version: 1.0
3
+ Version: 1.1.1
4
4
  Summary: A Dynamic Learning Model for processing NLP queries using hybrid AI and reasoning.
5
5
  Home-page: https://github.com/VigneshT24/Dynamic_Learning_Model
6
6
  Author: Vignesh Thondikulam
@@ -46,7 +46,7 @@ Whether you're building a student support bot, a domain-specific assistant, or a
46
46
 
47
47
  * This model uses SpaCy, SQLite, & NLTK for many of its functions
48
48
 
49
- NOTICE: You'll need to install, import, and configure your device to "SpaCy", "NLTK", and possibly SQLite for this bot to be used in programs (only for developers)
49
+ NOTICE: This is a public package, to install it, run: **pip install dynamic-learning-model**
50
50
 
51
51
 
52
52
  ![image](https://github.com/user-attachments/assets/340dc69a-8374-45df-ac1e-82431c5111f2)
@@ -16,7 +16,7 @@ Whether you're building a student support bot, a domain-specific assistant, or a
16
16
 
17
17
  * This model uses SpaCy, SQLite, & NLTK for many of its functions
18
18
 
19
- NOTICE: You'll need to install, import, and configure your device to "SpaCy", "NLTK", and possibly SQLite for this bot to be used in programs (only for developers)
19
+ NOTICE: This is a public package, to install it, run: **pip install dynamic-learning-model**
20
20
 
21
21
 
22
22
  ![image](https://github.com/user-attachments/assets/340dc69a-8374-45df-ac1e-82431c5111f2)
@@ -21,7 +21,6 @@ class DLM:
21
21
  __tone = None # sentimental tone of user query
22
22
  __trainingPwd = "371507" # password to enter training mode
23
23
  __mode = None # either "training", "commercial", or "experimental"
24
- __singlePassthrough = True # used to prevent multiple iterations of training prompt
25
24
  __unsure_while_thinking = False # if uncertain while thinking, then it will let the user know that
26
25
  __nlp_similarity_value = None # saves the similarity value by doing SpaCy calculation (for debugging)
27
26
  __special_stripped_query = None # saves query without any special words for reduced interference while vector calculating
@@ -259,11 +258,15 @@ class DLM:
259
258
  "quarter": 0.25, "quarters": 0.25
260
259
  }
261
260
 
262
- def __init__(self, db_filename): # initializes SQL database & SpaCy NLP
261
+ def __init__(self, mode, db_filename="dlm_database.db"): # initializes SQL database & SpaCy NLP
263
262
  """
264
263
  Initialize the Dynamic-Learning Model (DLM) chatbot.
265
264
 
266
265
  Parameters:
266
+ mode (str): The access mode. Options:
267
+ 't' for Training mode (to train the bot with queries),
268
+ 'c' for Commercial mode (to use it in your deployment/production program),
269
+ 'e' for Experimental mode (for arithmetic or conversion queries).
267
270
  db_filename (str): The SQLite database file used to train and retrieve
268
271
  question-answer-category triples.
269
272
 
@@ -271,13 +274,70 @@ class DLM:
271
274
  - Loads the SpaCy NLP model ('en_core_web_lg').
272
275
  - Loads Better-Profanity for profane phrase sensing.
273
276
  - Connects to the specified SQLite database file.
277
+ - Set appropriate mode value
278
+ - Verify login information based on mode
274
279
  - Ensures the required table structure exists (creates if missing).
275
280
  """
276
281
  self.__nlp = spacy.load("en_core_web_lg")
277
282
  profanity.load_censor_words()
278
283
  self.__filename = db_filename
284
+ self.__mode = mode
285
+ self.__login_verification(self.__mode)
279
286
  self.__create_table_if_missing()
280
287
 
288
+ def __login_verification(self, mode): # no return, void
289
+ """
290
+ Verify and initialize the selected access mode (Training, Commercial, or Experimental).
291
+
292
+ Parameters:
293
+ mode (str): The access mode. Options are:
294
+ 't' - Training mode (requires password and shows training guidelines)
295
+ 'c' - Commercial mode (no training features, read-only usage)
296
+ 'e' - Experimental mode (enables reasoning features, no DB writes)
297
+
298
+ Behavior:
299
+ - If mode is 't', prompts for a password and displays mandatory training instructions.
300
+ - If mode is 'c', enters Commercial mode without training privileges.
301
+ - If mode is 'e', proceeds with Experimental mode with reasoning capabilities.
302
+ """
303
+ if mode.lower() == "t":
304
+ password = input("Enter the password to enter Training Mode: ")
305
+ while password != self.__trainingPwd:
306
+ password = input(
307
+ "Password is incorrect, try again or type 'stop' to enter in commercial mode instead: ")
308
+ if password.lower() == "stop":
309
+ self.__mode = "commercial"
310
+ print("\n")
311
+ break
312
+ if password == self.__trainingPwd:
313
+ # trainers must understand these rules as DLM can generate bad responses if these instructions are neglected
314
+ print(
315
+ f"\n\n{'\033[31m'}MAKE SURE TO UNDERSTAND THE FOLLOWING ANSWER FORMAT EXPECTED FOR EACH CATEGORY FOR THE BOT TO LEARN ACCURATELY:{'\033[0m'}\n")
316
+ print("*'yesno': Make sure to start your answer responses with \"yes\" or \"no\" ONLY")
317
+ print(
318
+ "*'process': Each answer must have three steps for your responses, separated by \";\" (semicolon)")
319
+ print(
320
+ "*'definition': Make sure to not mention the WORD/PHRASE to be defined & always start your response here with \"the\" only")
321
+ print("*'deadline': Only include the deadline date, as an example, \"March 31st 2025\"")
322
+ print("*'location': Mention the location only, nothing else. For example, \"The FAFSA.Gov website\"")
323
+ print("*'generic': Format doesn't matter for this, give your answer in any comprehensive format")
324
+ print(
325
+ "*'eligibility': Make sure to ONLY start the response with a pronoun like \"you\", \"they\", \"he\", \"she\", etc\n\n")
326
+
327
+ confirmation = input(
328
+ "Make sure to understand and note these instructions somewhere as the generated responses would get corrupt otherwise.\nType 'Y' if you understood: ")
329
+ while confirmation.lower() != "y": # trainers must understand the instructions above
330
+ confirmation = input(
331
+ "You cannot proceed to train without understanding the instructions aforementioned. Type 'Y' to continue: ")
332
+ self.__mode = "training"
333
+ print("\n")
334
+ self.__loadingAnimation("Logging in as Trainer", 0.6)
335
+ print("\n")
336
+ elif mode.lower() == "c":
337
+ self.__mode = "commercial"
338
+ else:
339
+ self.__mode = "experimental"
340
+
281
341
  def __create_table_if_missing(self): # no return, void
282
342
  """
283
343
  Ensure the existence of the 'knowledge_base' table in the SQLite database; create or modify it if necessary.
@@ -1188,76 +1248,11 @@ class DLM:
1188
1248
  conn.commit()
1189
1249
  conn.close()
1190
1250
 
1191
- def __login_verification(self, mode): # no return, void
1192
- """
1193
- Verify and initialize the selected access mode (Training, Commercial, or Experimental).
1194
-
1195
- Parameters:
1196
- mode (str): The access mode. Options are:
1197
- 't' - Training mode (requires password and shows training guidelines)
1198
- 'c' - Commercial mode (no training features, read-only usage)
1199
- 'e' - Experimental mode (enables reasoning features, no DB writes)
1200
-
1201
- Behavior:
1202
- - If mode is 't', prompts for a password and displays mandatory training instructions.
1203
- - If mode is 'c', enters Commercial mode without training privileges.
1204
- - If mode is 'e', proceeds with Experimental mode with reasoning capabilities.
1205
- """
1206
- if mode.lower() == "t":
1207
- password = input("Enter the password to enter Training Mode: ")
1208
- while password != self.__trainingPwd:
1209
- password = input(
1210
- "Password is incorrect, try again or type 'stop' to enter in commercial mode instead: ")
1211
- if password.lower() == "stop":
1212
- self.__mode = "commercial"
1213
- print("\n")
1214
- self.__loadingAnimation("Logging in as Commercial User", 0.6)
1215
- print("\n")
1216
- break
1217
- if password == self.__trainingPwd:
1218
- # trainers must understand these rules as DLM can generate bad responses if these instructions are neglected
1219
- print(
1220
- f"\n\n{'\033[31m'}MAKE SURE TO UNDERSTAND THE FOLLOWING ANSWER FORMAT EXPECTED FOR EACH CATEGORY FOR THE BOT TO LEARN ACCURATELY:{'\033[0m'}\n")
1221
- print("*'yesno': Make sure to start your answer responses with \"yes\" or \"no\" ONLY")
1222
- print(
1223
- "*'process': Each answer must have three steps for your responses, separated by \";\" (semicolon)")
1224
- print(
1225
- "*'definition': Make sure to not mention the WORD/PHRASE to be defined & always start your response here with \"the\" only")
1226
- print("*'deadline': Only include the deadline date, as an example, \"March 31st 2025\"")
1227
- print("*'location': Mention the location only, nothing else. For example, \"The FAFSA.Gov website\"")
1228
- print("*'generic': Format doesn't matter for this, give your answer in any comprehensive format")
1229
- print(
1230
- "*'eligibility': Make sure to ONLY start the response with a pronoun like \"you\", \"they\", \"he\", \"she\", etc\n\n")
1231
-
1232
- confirmation = input(
1233
- "Make sure to understand and note these instructions somewhere as the generated responses would get corrupt otherwise.\nType 'Y' if you understood: ")
1234
- while confirmation.lower() != "y": # trainers must understand the instructions above
1235
- confirmation = input(
1236
- "You cannot proceed to train without understanding the instructions aforementioned. Type 'Y' to continue: ")
1237
- self.__mode = "training"
1238
- print("\n")
1239
- self.__loadingAnimation("Logging in as Trainer", 0.6)
1240
- print("\n")
1241
- elif mode.lower() == "c":
1242
- self.__mode = "commercial"
1243
- self.__loadingAnimation("Logging in as Commercial User", 0.6)
1244
- print("Ask Non-Computational Queries (switch to experimental for computational queries)")
1245
- else:
1246
- self.__mode = "experimental"
1247
- self.__loadingAnimation("Logging in as Experimental", 0.6)
1248
- print("Ask Computational Problems (Arithmetics or Conversions)")
1249
-
1250
- def ask(self, mode): # no return, void
1251
+ def ask(self, query): # no return, void
1251
1252
  """
1252
1253
  Handle a full user interaction loop with the DLM bot.
1253
1254
  NOTICE: To make the bot run continuously, implement a loop in your program
1254
1255
 
1255
- Parameters:
1256
- mode (str): The access mode. Options:
1257
- 't' for Training mode,
1258
- 'c' for Commercial mode,
1259
- 'e' for Experimental mode.
1260
-
1261
1256
  Behavior:
1262
1257
  - Prompts the user for input.
1263
1258
  - Detects tone, filters input, searches knowledge base.
@@ -1266,18 +1261,7 @@ class DLM:
1266
1261
  - If in training mode and answer is incorrect or not found, prompts user to teach the bot.
1267
1262
  - In experimental mode, performs reasoning or arithmetic without using database.
1268
1263
  """
1269
- if self.__singlePassthrough:
1270
- self.__login_verification(mode)
1271
- self.__singlePassthrough = False
1272
-
1273
- if self.__mode == "training":
1274
- print("\nTRAINING MODE")
1275
- elif self.__mode == "commercial":
1276
- print("\n\nCOMMERCIAL MODE")
1277
- else:
1278
- print("\n\nEXPERIMENTAL MODE") # for experimental, there are no data saving in DB
1279
- self.__query = input("DLM Bot here, ask away: ")
1280
-
1264
+ self.__query = query
1281
1265
  while self.__query is None or self.__query == "":
1282
1266
  self.__query = input("Empty input is unacceptable. Please enter something: ")
1283
1267
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dynamic-learning-model
3
- Version: 1.0
3
+ Version: 1.1.1
4
4
  Summary: A Dynamic Learning Model for processing NLP queries using hybrid AI and reasoning.
5
5
  Home-page: https://github.com/VigneshT24/Dynamic_Learning_Model
6
6
  Author: Vignesh Thondikulam
@@ -46,7 +46,7 @@ Whether you're building a student support bot, a domain-specific assistant, or a
46
46
 
47
47
  * This model uses SpaCy, SQLite, & NLTK for many of its functions
48
48
 
49
- NOTICE: You'll need to install, import, and configure your device to "SpaCy", "NLTK", and possibly SQLite for this bot to be used in programs (only for developers)
49
+ NOTICE: This is a public package, to install it, run: **pip install dynamic-learning-model**
50
50
 
51
51
 
52
52
  ![image](https://github.com/user-attachments/assets/340dc69a-8374-45df-ac1e-82431c5111f2)
@@ -5,7 +5,7 @@ with open('README.md', 'r', encoding='utf-8') as f:
5
5
 
6
6
  setup(
7
7
  name='dynamic-learning-model',
8
- version='1.0',
8
+ version='1.1.1',
9
9
  author='Vignesh Thondikulam',
10
10
  author_email='vignesh.tho2006@gmail.com',
11
11
  description='A Dynamic Learning Model for processing NLP queries using hybrid AI and reasoning.',