ai_chatbot 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ai_chatbot/version.rb +1 -1
- data/lib/ml_model.py +18 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12bcba7047f40d05685eec1c6a6714d7b8b6d57b092df1dcf6e382040af48182
|
4
|
+
data.tar.gz: ede7b3ccff3faecf008c681c649f7ac3732bebbd2a46f7801a313a0d64507ce4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 991397292bed26854442cc630a87539fbb3ccba1cf81f6af673db57b607e56fdf150d4d905b00709b2c81ea6b4510759d7785f6ba16e44d58eab6e371b4ee581
|
7
|
+
data.tar.gz: f5312f608a08cffac6ef4ad93b4e7aed47191fdf0af0b7337a93bc13a9605e09db4eec91176b7dcc16c155af310d38d359fb03314bdd918b291f008579b56926
|
data/lib/ai_chatbot/version.rb
CHANGED
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.
|
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.
|
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-
|
11
|
+
date: 2024-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open3
|
@@ -35,10 +35,11 @@ files:
|
|
35
35
|
- lib/ai_chatbot.rb
|
36
36
|
- lib/ai_chatbot/version.rb
|
37
37
|
- lib/ml_model.py
|
38
|
-
homepage:
|
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:
|