<div align="center">
    <p><a href="#"><a href="https://ollama.ai/"><img alt="ollama" src="./imgs/ollama-icon.png" width="200px" /></a><img alt="+" src="./imgs/grey-plus.png" width="100px" /></a><a href="https://discord.com/"><img alt="discord" src="./imgs/discord-icon.png" width="195px" /></a></p>
    <h1>Discord Ollama Chatbot Integration</h1>
    <h3><a href="#"></a>A Discord chatbot with a little "magic" added</h3>
    <h3><a href="#"></a>A fork of https://github.com/kevinthedang/discord-ollama</h3>
</div>

## About/Goals v 1.0
Ollama is an AI model management tool that allows users to install and use custom large language models locally.  
The project aims to:
* [x] Create a Discord bot that will utilize Ollama and chat to chat with users! 
  * [x] User Preferences on Chat
  * [x] Message Persistance on Channels and Threads
    * [x] Threads
    * [x] Channels
  * [x] Containerization with Docker
  * [x] Slash Commands Compatible
  * [x] Generated Token Length Handling for >2000
    * [x] Token Length Handling of any message size
  * [x] User vs. Server Preferences
  * [ ] Redis Caching
  * [x] Administrator Role Compatible
  * [x] Multi-User Chat Generation (Multiple users chatting at the same time) - This was built in from Ollama `v0.2.1+`
  * [x] Automatic and Manual model pulling through the Discord client
  * [x] Leverage function calling capabilities in Gemma3
    * [x] json-formatted replies allowing hidden COT and statefulness 
    * [x] base ollama system prompt providing json formatting, jailbreak resistance, and sentiment tracking
    * [ ] function calling to imagegen
    * [ ] integrate image recognition
  * [x] Store self- and per-user-sentiment in redis
    * [x] tell the model to create redis set and get commands itself
  * [x] Separate bot personality from base bot instructions (src/personality.json)


## Documentation
These are guides to the features and capabilities of this app.
* [User Slash Commands](./docs/commands-guide.md)
* [Client Events](./docs/events-guide.md)

## Environment Setup
* Clone this repo using `git clone https://gitea.matrixwide.com/alex/discord-aidolls` 
* You will need a `.env` file in the root of the project directory with the bot's token. There is a `.env.sample` is provided for you as a reference for what environment variables.
    * For example, `CLIENT_TOKEN = [Bot Token]`
* Please refer to the docs for bot setup.
    * [Creating a Discord App](./docs/setup-discord-app.md)
    * [Local Machine Setup](./docs/setup-local.md)
    * [Docker Setup for Servers and Local Machines](./docs/setup-docker.md)
        * Nvidia is recommended for now, but support for other GPUs should be development.
        * Local use is not recommended.

## Resources
* [NodeJS](https://nodejs.org/en)
    * This project runs on `lts\jod` and above. 
    * This project requires the use of npm version `10.9.0` or above.
* [Ollama](https://ollama.com/)
    * [Ollama Docker Image](https://hub.docker.com/r/ollama/ollama)
* [Redis](https://redis.io/)
    * [Redis Docker Image](https://hub.docker.com/_/redis)
* [Discord.js Docs](https://discord.js.org/docs/packages/discord.js/main)
* [Setting up Docker (Ubuntu 20.04)](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04)
    * [Setting up Nvidia Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)

## Acknowledgement
* [Kevin Dang](https://github.com/kevinthedang)
* [Jonathan Smoley](https://github.com/JT2M0L3Y)
