AssistantBot is a python package which provides an question-answering system designed to process large datasets efficiently. It dynamically matches user queries with relevant data, offering accurate responses and easy training process.
Project description
Assistant AI
Assistant AI is a simple conversational assistant package that uses predefined questions and answers to provide relevant responses. The package also supports training, where you can add new questions and answers dynamically.
Features
- Predefined Question & Answer Model: The assistant can respond to predefined questions using a JSON file.
- Dynamic Training: You can train the assistant with new questions and answers.
- Close Match Question Detection: Uses
difflib
to match input questions with the closest possible question in the model. - Simple and Flexible: Easy to extend or modify.
Installation
Clone the repository and navigate to your project folder:
git clone https://github.com/wassim-khleifi/ai_assistantbot.git
cd ai_assistantbot
You can install the package using pip:
pip install .
Or install via pypi:
pip install ai_assistantbot
Usage:
Initializing the Assistant:
First, import and initialize the Assistant class with the path to the JSON file that stores the model data:
import ai_assistantbot
from ai_assistantbot import Assistant
# Initialize the assistant with the model JSON file
assistant = Assistant('path_to_your_model.json')
# Register the base model (if not created)
assistant.register()
Query the Assistant:
Use the get_answer
method to fetch answers based on user questions:
response = assistant.get_answer("hi", not_found="Sorry, I don't understand")
print(response) # Output: Hey there!
Train the Assistant
You can train the assistant by providing new questions and answers:
new_questions = ["how are you", "how's it going"]
new_answers = ["I'm doing great, thanks!", "All good!"]
assistant.train_model(new_questions, new_answers)
Example:
This example is taken from examples/example.py
import ai_assistantbot
from ai_assistantbot.assistant import *
# Initialize the assistant with the model JSON file
assistant = Assistant('example.json')
assistant.register() # Register the base model (if not created)
while True:
user_input = input('You: ')
response = assistant.get_answer(str(user_input), not_found="Sorry, I don't understand")
print('Bot: ' + response)
Contributing:
Contributions are welcome! Please fork this repository, make your changes, and submit a pull request.
License:
This project is licensed under the MIT License:
MIT License
Copyright (c) 2024 Wassim Khleifi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ai_assistantbot-0.0.10.tar.gz
.
File metadata
- Download URL: ai_assistantbot-0.0.10.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e26248d0b47dddb5dcfde8b82ab23b7283518142f90029475ca19a223ad344bd |
|
MD5 | 1a882f4a32ffca68090c227689fa990b |
|
BLAKE2b-256 | cce5a61d274cc17e1e94fe701c1761291d7f6b167321cedf612212844b1819fd |
File details
Details for the file ai_assistantbot-0.0.10-py3-none-any.whl
.
File metadata
- Download URL: ai_assistantbot-0.0.10-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaa96d638749c1917de045539cfcb62a71c86368186c7eeb879ef8dd6be241ba |
|
MD5 | ec34f84a0f17f3bf2683b09f951479e5 |
|
BLAKE2b-256 | 0ad2c0f7089f62bef1173fcd3354f3be07e36c79a8d7e0c78ff1617b96ce0f7a |