DEV Community

Cover image for ๐Ÿง  Pythonaibrain
Divyanshu Sinha
Divyanshu Sinha

Posted on Edited on

๐Ÿง  Pythonaibrain

Make your first AI Assistant in Python with just an intents.json file. No complex setup. No advanced coding. Just install, configure, and run!

๐Ÿš€ Features

โœ… Simple setup using JSON-based intents

๐Ÿง  Built-in NER (Named Entity Recognition) training

๐Ÿ” AI prediction and response handling

๐Ÿ“š Easy to integrate into chatbots

๐Ÿ”ง Installation

pip install pythonaibrain

๐Ÿงช Quick Start

  1. Create an intents.json file like this:
    {
    "intents": [
    {
    "tag": "greeting",
    "patterns": ["Hi", "Hello", "How are you?"],
    "responses": ["Hello!", "Hi there!", "Greetings!"]
    },
    {
    "tag": "goodbye",
    "patterns": ["Bye", "See you", "Goodbye"],
    "responses": ["Goodbye!", "Take care!", "See you soon!"]
    }
    ]
    }

  2. Create your Python file:
    `
    from os import system
    from pyai import Brain

brain = Brain("your/dataset/path/intents.json") # Enter Path of your dataset.

while True:
message = input('Message : ')
message_type = brain.predict_message_type(message)

if message_type == 'Question' or message_type == "Answer":
    brain.pyai_say(brain.process_messages(message))

if message_type == "Shutdown":
    system(message)
Enter fullscreen mode Exit fullscreen mode

`

๐Ÿ“ฆ Project Links

๐Ÿ“Œ PyPI: https://pypi.org/project/pythonaibrain/1.0.1/

๐ŸŒ GitHub: https://github.com/World-Of-Programming-And-Technology/PythonAI

๐Ÿ› ๏ธ How It Works

NER Training: Tags patterns with named entities

Model Building: Learns from examples using deep learning

Prediction Engine: Returns the best matching response for input

โ— Trouble?

If you see an error like:

ValueError: num_samples should be a positive integer value, but got num_samples=0
Make sure your intents.json has at least one tag with non-empty patterns.

๐Ÿ“œ License

LGPL-2.1 license โ€“ feel free to use, modify, and share!

Top comments (0)