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
difflibto 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.
Metadata
Release files for ai-assistantbot 0.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ai_assistantbot-0.0.11.tar.gz | 4.7 kB | Without provenance | Details for ai_assistantbot-0.0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ai_assistantbot-0.0.11-py3-none-any.whl | Python 3 | none | any | Details for ai_assistantbot-0.0.11-py3-none-any.whl |
Total release size: 10.0 kB
Release files / ai_assistantbot-0.0.11.tar.gz
| Download URL | ai_assistantbot-0.0.11.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8ac2a339f0e26317a421ebd142901167c5175ec4ccfd05bd96ae1834795e1c7
|
|
BLAKE2b-256 checksum How to use checksums |
8419f6762c90465e6876df36703a85b9d2cfb0a9a2c6238e4fa193178b4c2ecc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.6
|
Release files / ai_assistantbot-0.0.11-py3-none-any.whl
| Download URL | ai_assistantbot-0.0.11-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
113be75f79c4dd3a30a73a58edde3d20e17d7fc7575f3e3f63c5fde9f0d5c1d6
|
|
BLAKE2b-256 checksum How to use checksums |
c830d625ecd37d3f15474972e9496014ad81e17d993f40e37ca2ed2534d66257
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.6
|
Security for ai-assistantbot 0.0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.