Giter Club home page Giter Club logo

jonbot's Introduction

jonbot

a friendly machine whats nice to talk to

This is a template repo, clone it and make your own friendo! Or use mine or whatever! No kings, no masters!

this bot helped me build this bot!

🤖❤️✨


jonbot is a chatbot with multiple frontends (Discord, Telegram) powered by AI through LangChain and connected to a MongDB database.

Installation

Create and activate an environment: e.g.

conda create -n jonbot-env python=3.11
conda activate jonbot-env

Clone the repo:

git clone https://github.com/jonmatthis/jonbot
cd jonbot

Install dependencies:

pip install -e .

Setup

Building yr Bot Buddy

Environment Variables

Setting up your project .env file

Set up the bot's config .toml file

  1. Choose a nickname for your bot

    • this can be anything and is only used behind the scenes (e.g. it doesn't affect the bot's displayed Username or anything).
    • I recommend something short, all lower case, and ending with the word 'bot', e.g. jonbot)
  2. Copy this nickname into the BOT_NICK_NAMES filed of the .env file (if using multiple bots, separate them with a comma, e.g. BOT_NICK_NAMES=jonbot,otherbot,yetanotherbot)

  3. Make a copy of the /jonbot/system/bot_tomls/_sample_config.toml file and rename it to [your_bots_nickname]_config.toml

    • You will fill in the DISCORD_TOKEN field after setting up the Discord Application (below)

Create a Discord Bot/Application

  1. Go to https://discord.com/developers/applications
  2. Click New Application
  3. Give your application a name (this will be the name of your bot)
  4. Click Bot in the left sidebar
    • Enable Privileged Gateway Intents (this is required for the bot to work)
      • Check all three tabs:
        • "Presence Intent"
        • "Server Members Intent"
        • "Message Content Intent"
    • Click Copy under DISCORD_TOKEN and paste it into the token field in your config file
  5. Click OAuth2 in the left sidebar
    • Under OAuth2 URL Generator
    • in 'SCOPES' check bot
    • in 'BOT PERMISSIONS' check Administrator if you're lazy/reckless like me, or check the individual permissions you want your bot to have if you're nervous/careful about permissions
    • Copy the URL in the SCOPES box and paste it into your browser and invite your bot to your server

Software

Run the Bot:

  • Create/activate a python 3.11 environment
  • install dependencies: pip install -e .
  • run: python -m jonbot.__main__.py 🤖❤️✨
  • The bot should now be running and you should see it online in your Discord server!

Run with Docker:

  • cd into jonbot/docker
  • run: docker-compose up --build -d
  • The bot should now be running and you should see it online in your Discord server!

Usage

  • Interact with the bot through Discord (text and voice memos)
  • API endpoints provide programmatic access to core functionality
  • __main__.py starts up all services

Architecture

graph TD
    classDef actor fill: #9E9E9E, stroke: #757575, stroke-width: 2px, color: #000, rounding: 5px;
    classDef interface fill: #90A4AE, stroke: #757575, stroke-width: 2px, color: #000, rounding: 5px;
    classDef api fill: #A5D6A7, stroke: #757575, stroke-width: 2px, color: #000, rounding: 5px;
    classDef core fill: #FFE082, stroke: #757575, stroke-width: 2px, color: #000, rounding: 5px;
    classDef data fill: #FFAB91, stroke: #757575, stroke-width: 2px, color: #000, rounding: 5px;
    A(["External User"]):::actor

    subgraph JonBot
        subgraph Frontend User Interfaces
            B1["Current:\nDiscord"]:::interface
            B2["Planned:\nSlack, WebApp, Android, etc"]:::interface
        end

        subgraph Backend
            C["API Interface (FastAPI)"]:::api

            subgraph Controller
                D["Controller"]:::core
                E["BackendDatabaseOperations"]:::core
                F["Core Processes:\n(Chatbot, etc)"]:::core
            end

            subgraph Data Layer
                G["Database MongoDB"]:::data
                H(["Pydantic Data Models"]):::data
            end
        end

    end
    A <--> B1
    A <--> B2
    B1 <--> C
    B2 <--> C
    C <--> D
    D <--> E
    D <--> F
    E <--> G

Layer 0 - Frontends

  • discord_bot: Discord bot client and event handlers
  • telegram_bot: Telegram bot client and handlers

Layer 1 - API Interface

  • app.py: FastAPI application with endpoints

Layer 2 - Core Processes

  • ai_chatbot: LangChain setup and processing
  • audio_transcription: Transcribing audio to text with Whisper

Layer 3 - Data Layer

  • database: MongoDB integration
  • data_models: Pydantic models for data
  • system: Configuration and utilities

jonbot's People

Contributors

jackal37 avatar jonmatthis avatar mocapmike avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.