ai_chatbot 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1ecd8a87638329fd5c23080f6221814629a99b734c0952023d03114c1da8d9f
4
- data.tar.gz: ddeb90ba2ae48a4b88adacc58ceb6cd3898498ae08ba7c0323c4e676a64343dc
3
+ metadata.gz: 44d4375b7617e626f0ece5d48d9951db6cbb29d40fc039ed432f57f95214ff61
4
+ data.tar.gz: b47d32642a89b0a8ee430d210d57fa310616828938e431cf5b9094b1720e9d92
5
5
  SHA512:
6
- metadata.gz: '0176796cd767ea1f9f069e61706d61d6aa9a767c67d284b3651a0b3df08c924a915fdfd72cb24c6231c4dcce2fc36acbf352e3c0fd0377d83427416e820ecf97'
7
- data.tar.gz: 4dd0ef6b1cc5eed4910d92a410a1104f77c10946e0dd0988e8d572a6672ed0bda9d4c6bc1219ea27903ee14668cdbbca5bbc1143012f247a88471c3a5ccd6e0e
6
+ metadata.gz: 2b85bdabf2fcf579a8355ef6b847251b6f1a715ef648a70bdbff1d4807f3615b425c50b80ce54f653477ae4c4caa163c8614e9563364a75145ff346b369077c3
7
+ data.tar.gz: 1fd7b59dde9c05e0ebca46fb472365786e7dbeb6440d2b30c7a0239246343efb8c3cb617aad4a83c48af2c3d18daab3726aaf6f672ea20b33bfbaa012995b94c
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AiChatbot
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/ml_model.py CHANGED
@@ -34,6 +34,10 @@ def main(action, query=None, new_answer=None):
34
34
  return get_prediction(query)
35
35
  elif action == "train":
36
36
  return train_model(query, new_answer)
37
+ elif action == "update":
38
+ return update_answer(query, new_answer)
39
+ elif action == "list":
40
+ return list_questions()
37
41
 
38
42
  # Function to predict the response with confidence check
39
43
  def get_prediction(query):
@@ -68,6 +72,27 @@ def train_model(new_question, new_answer):
68
72
 
69
73
  return f"Model retrained with the new question: '{new_question}' and answer: '{new_answer}'"
70
74
 
75
+ def update_answer(existing_question, new_answer):
76
+ global questions, answers
77
+
78
+ if existing_question in questions:
79
+ # Find the index of the existing question
80
+ index = questions.index(existing_question)
81
+ # Update the answer
82
+ answers[index] = new_answer
83
+ # Retrain the model with updated data
84
+ model.fit(questions, answers)
85
+ # Save the updated model and data
86
+ with open("qa_model.pkl", "wb") as f:
87
+ pickle.dump({"questions": questions, "answers": answers}, f)
88
+ return f"Answer updated for the question: '{existing_question}'"
89
+ else:
90
+ return "Question not found. Please provide a valid question."
91
+
92
+ def list_questions():
93
+ global questions
94
+ return questions
95
+
71
96
  if __name__ == "__main__":
72
97
  # Expecting action (predict/train), question, and answer (if training)
73
98
  action = sys.argv[1]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ai_chatbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sanet