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)