Skip to content

teodorgross/ollama_bot_discord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Overview

This project is a Discord bot that leverages a local AI (via Ollama) and a SearxNG-based web search to provide extended chat functionalities. The main features include:

  1. /ask
  • Pose any question to the bot and receive an AI-powered response, optionally supplemented with search results from a SearxNG instance.
  1. /summary
  • Summarize the content of a specific website by scraping it and then analyzing the text using Ollama.
  1. /doc

    • Upload a Word or Excel file (PDF not supported) and optionally ask a follow-up question.
    • The bot reads the file contents (e.g., converting .docx to text via Mammoth or .xlsx via SheetJS), combines the extracted text with your question, and then analyzes/summarizes it using Ollama.
    • Useful for quick overviews, Q&A, or short analyses of document-based data within Discord.

Additional utilities include:

  • Scraping websites (via SearxNG or direct single-URL scraping)

  • Interfacing with Ollama for AI responses (local LLM running on your machine)

  • Centralized configuration in a config.json file for easy adaptation (Discord token, guild IDs, default AI model, etc.).

Project Goals

  • Run a Discord bot that communicates with a local AI backend (Ollama).

  • Incorporate a web search step (SearxNG) for context-based answers and summaries.

  • Provide a clean, extensible structure so new slash commands or additional features can be introduced quickly.


Installation and Setup

Requirements

  • Node.js (version 16.9 or higher recommended)

  • NPM (or Yarn)

  • A working Ollama setup (listening on port 11434 or configured otherwise)

  • An optional SearxNG instance for web searches (e.g., local instance on port 9090)

Steps

  1. Clone or download the repository

Create a folder and place the project files inside.

  1. Install dependencies
npm install
  1. Configure config.json

Edit config.json (located in the project’s root or src folder, depending on structure) and fill in your own values, for example:

``

{

"token": "YOUR_DISCORD_BOT_TOKEN",

"client_id": "YOUR_CLIENT_ID",

"guild_id": "YOUR_GUILD_ID",

"ollama_url": "http://localhost:11434/",

"default_model": "gemma2:9b",

"assistant_description": "You are a helpful assistant that always responds kindly and accurately in German."


}

token: Your Discord bot token (retrieved via the Discord Developer Portal).

client_id: Your bot application’s Client ID.

guild_id: The ID of the server you plan to use for testing the slash commands.

ollama_url: The address for your Ollama instance (defaults to http://localhost:11434).

default_model: The AI model (e.g., gemma2:9b) that Ollama should use.

assistant_description: What the Assistant Goals are and in which language he should respond

  1. Run the bot
node ./src/main.js

Upon starting, you should see console messages about successfully registering commands in your guild.

Verify functionality

In the Discord server matching your guild_id, type /ask or /summary. If all is well, the bot will respond.

Ensure your Ollama server is running (e.g., check with curl http://localhost:11434) so the AI prompts can be processed.

Bot Invite & Permissions

Make sure you invited the bot to your server with the applications.commands scope.

The bot should have at least Manage Guild or Administrator permissions to smoothly register slash commands.

Once completed, your bot is ready to answer /ask queries (optionally with web search) and generate /summary results by scraping target URLs and feeding them into Ollama.

About

A Discord bot that leverages a local AI (via Ollama) and a SearxNG-based web search to provide extended chat functionalities.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors