ai_chatbot 0.1.1 → 0.1.3
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 +25 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc3178f23280f489a71840d4b605097868f6c0aeb35b7790701232441a06e000
|
4
|
+
data.tar.gz: 0f64ab1e191a453914e2b42e4bcee8dc350e93672b393c8e475e72c66ba9e061
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63f32775fefb298627912c672ad243a64a8b3dd70a4e2995f87ce980d73071c11823ecede02b6a31622f70a6d5dcdb131bc1615afa68387817af778821cbd9f0
|
7
|
+
data.tar.gz: 21b5d01971f6d897c18c85acc55417cfdca2bfbb56f857f0427ec0e47d6c236272a604b3f7c8fe759fb9001bc7b490e0e47ac5b813276d3412a150d3e583883c
|
data/lib/ai_chatbot/version.rb
CHANGED
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,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.3
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open3
|
@@ -35,7 +35,7 @@ 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
41
|
metadata: {}
|