ai_chatbot 0.1.3 → 0.1.4

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: fc3178f23280f489a71840d4b605097868f6c0aeb35b7790701232441a06e000
4
- data.tar.gz: 0f64ab1e191a453914e2b42e4bcee8dc350e93672b393c8e475e72c66ba9e061
3
+ metadata.gz: 12bcba7047f40d05685eec1c6a6714d7b8b6d57b092df1dcf6e382040af48182
4
+ data.tar.gz: ede7b3ccff3faecf008c681c649f7ac3732bebbd2a46f7801a313a0d64507ce4
5
5
  SHA512:
6
- metadata.gz: 63f32775fefb298627912c672ad243a64a8b3dd70a4e2995f87ce980d73071c11823ecede02b6a31622f70a6d5dcdb131bc1615afa68387817af778821cbd9f0
7
- data.tar.gz: 21b5d01971f6d897c18c85acc55417cfdca2bfbb56f857f0427ec0e47d6c236272a604b3f7c8fe759fb9001bc7b490e0e47ac5b813276d3412a150d3e583883c
6
+ metadata.gz: 991397292bed26854442cc630a87539fbb3ccba1cf81f6af673db57b607e56fdf150d4d905b00709b2c81ea6b4510759d7785f6ba16e44d58eab6e371b4ee581
7
+ data.tar.gz: f5312f608a08cffac6ef4ad93b4e7aed47191fdf0af0b7337a93bc13a9605e09db4eec91176b7dcc16c155af310d38d359fb03314bdd918b291f008579b56926
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AiChatbot
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/ml_model.py CHANGED
@@ -48,7 +48,7 @@ def get_prediction(query):
48
48
  similarities = cosine_similarity(query_vec, question_vecs)
49
49
  max_similarity = similarities.max()
50
50
 
51
- threshold = 0.70
51
+ threshold = 0.65
52
52
  if max_similarity < threshold:
53
53
  return "No good match found. Please provide the correct answer."
54
54
  else:
@@ -89,6 +89,23 @@ def update_answer(existing_question, new_answer):
89
89
  else:
90
90
  return "Question not found. Please provide a valid question."
91
91
 
92
+ def update_question(existing_question, new_question):
93
+ global existing_question, new_question
94
+
95
+ if existing_question in questions:
96
+ # Find the index of the existing question
97
+ index = questions.index(existing_question)
98
+ # Update the answer
99
+ existing_question[index] = new_question
100
+ # Retrain the model with updated data
101
+ model.fit(questions, answers)
102
+ # Save the updated model and data
103
+ with open("qa_model.pkl", "wb") as f:
104
+ pickle.dump({"questions": questions, "answers": answers}, f)
105
+ return f"New question updated for the question: '{existing_question}'"
106
+ else:
107
+ return "Question not found. Please provide a valid question."
108
+
92
109
  def list_questions():
93
110
  global questions
94
111
  return questions
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ai_chatbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sanket
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-19 00:00:00.000000000 Z
11
+ date: 2024-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open3
@@ -38,7 +38,8 @@ files:
38
38
  homepage: https://github.com/tikhandesanket/ai-chatbot
39
39
  licenses:
40
40
  - MIT
41
- metadata: {}
41
+ metadata:
42
+ source_code_uri: https://github.com/tikhandesanket/ai-chatbot
42
43
  post_install_message:
43
44
  rdoc_options: []
44
45
  require_paths: