Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_assistantbot-0.0.11.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

ai_assistantbot-0.0.11-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file ai_assistantbot-0.0.11.tar.gz.

File metadata

  • Download URL: ai_assistantbot-0.0.11.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.6

File hashes

Hashes for ai_assistantbot-0.0.11.tar.gz
Algorithm Hash digest
SHA256 d8ac2a339f0e26317a421ebd142901167c5175ec4ccfd05bd96ae1834795e1c7
MD5 41813ed31d178e4ae00cbda4c8482a82
BLAKE2b-256 8419f6762c90465e6876df36703a85b9d2cfb0a9a2c6238e4fa193178b4c2ecc

See more details on using hashes here.

File details

Details for the file ai_assistantbot-0.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_assistantbot-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 113be75f79c4dd3a30a73a58edde3d20e17d7fc7575f3e3f63c5fde9f0d5c1d6
MD5 23f6c71bc7482e4561c0a797a7d6e6a4
BLAKE2b-256 c830d625ecd37d3f15474972e9496014ad81e17d993f40e37ca2ed2534d66257

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page