Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zeyoyt/ailama
a discord user installable app for ai response using ollama, JDA-5 and LangChain4J
https://github.com/zeyoyt/ailama
Last synced: 3 months ago
JSON representation
a discord user installable app for ai response using ollama, JDA-5 and LangChain4J
- Host: GitHub
- URL: https://github.com/zeyoyt/ailama
- Owner: ZeyoYT
- License: mit
- Created: 2024-04-19T02:36:20.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-09-17T19:49:22.000Z (4 months ago)
- Last Synced: 2024-09-18T17:38:14.341Z (4 months ago)
- Language: Java
- Size: 338 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- Awesome-Ollama - AiLama
README
# AiLama
A User Installable Discord App, made using JDA-5 ( java discord api 5 ), LangChain4J, and using Ollama to provide Ai Response anywhere in discord
Please Read : [Important Things to Consider](#important-things-to-consider-before-using-the-project)
## Table of Contents
- [Features](#features)
- [Prerequisite](#prerequisite)
- [How-To](#how-to)
- [Whitelisting Other People to use the App](#whitelisting-other-people-to-use-the-app)
- [Important Things to Consider before Using the Project](#important-things-to-consider-before-using-the-project)
- [Limitations](#limitations)
- [Run Using Docker](#run-using-docker)
- [Using Docker Compose](#docker-compose-file-)
- [Manual Method](#manual-method--)
- [Build Docker Image Your self](#build-docker-image-your-self)
- [SearXNG Guide](#searxng-guide)
- [Setting SearXNG](#setting-searxng--)
- [Adding Environment Variables to AiLama](#adding-environment-variables-to-ailama--)
- [List of Commands](#list-of-commands--)
## Features
- Simple To Use
- Web Search Capabilities using SearXNG
- Web Document for RAG Support using URL
- Function Calling on AI Command with DOT Notation ( example below )
- Normal Document Support
- can be used anywhere in discord where user installable apps are supported
- you can run you query by a different model on the fly using the model's field ( example below )
## Prerequisite
### Ollama :
_Ollama is an open-source app that lets you run, create, and share large language models locally with a command-line interface_
- Ollama 0.28 or Greater ( [Download Here](https://ollama.com/download) )
- Ai Model for Ollama ( [Download Here](https://ollama.com/models) ) [ [llama3](https://ollama.com/library/llama3) Preferred ]
**_There are Two ways you can use AiLama, by using Docker Image or by Building the Project and Running it_**
### Compile and Run
- Java 19 or Greater
- Gradle 7.6 or Greater ( [Download Here](https://gradle.org/) )### Run without Compiling
- Docker ( [Download Here](https://www.docker.com/) )
### Discord App
- A Discord Bot/App ( make __[New](https://discord.com/developers/applications)__ app from discord developer portal )
## Optional Prerequisite
_These are Optional Prerequisite, you can use the bot without them, but to get access to more features its recommended to install the following programs_
### Web Search
- SearXNG for Web Search ( [Setup Here](https://github.com/searxng/searxng?tab=readme-ov-file#setup) ) ( [Guide by AiLama Here](#searxng-guide) )### Image Generation
- Automatic1111 for Image Generation ( [ Download Here ](https://github.com/AUTOMATIC1111/stable-diffusion-webui) )
## How-To
1. First Clone this Repo
```
https://github.com/ZeyoYT/AiLama.git
```2. Change Directory
```
cd AiLama
```3. Create Dot Env File ( check [.env.example](https://github.com/ZeyoYT/AiLama/blob/master/.env.example) ) and Fill Details
```
mv ./.env.example ./.env
```5. Build Project
```
./gradlew build
```
After Building the project, a new Jar File would be made in `AiLama/build/shadow/`, that jar file can now be used to run the bot using the following command
```
java -jar ./.jar
```
## How to Make a new Discord Installable App and Install it
1. Go to `https://discord.com/developers/applications`
2. Click 'New Application' button
3. Give it a Name and agree to TOS and Developer Policy
4. Go to Bot and Un-Select Public Bot and Enable Presence Intent & Server Members Intent
5. Click on Reset Token and Reset the bot's token
6. Copy the Shown Token and Paste it in the `.env` file
7. Save the changes
8. Go to Installation and Un-Select Guild Install, and Select User Install
9. in Install Link select `Discord Provided Link`, then copy the link and open it
10. Authorize the App
## Whitelisting Other People to use the App
_Using the Authorization Link, you can allow others to install the app, but to actually use the app you need to whitelist them_
In the Dot Env File ( .env ), there is a field called `WHITELISTED_USERS`, it must be shown something like this
```dotenv
WHITELISTED_USERS='WHITELISTED_USER_ID_HERE, WHITELISTED_USER_ID_HERE, ...'
```
in this you need to add there User ID's inside a single quote seperated by coma ( , ), for Example
```dotenv
WHITELISTED_USERS='426802118683262976, 259214353931304963, 848561799132741652'
```
**Note:** After Authorization of app, they might need to restart discord for the app to show up, and the app must be running, or else the command wont be registerd
## Important Things to Consider before Using the Project
1. This is a side project, i will try my best to maintain it
2. You Need to run the Bot to use the command and keep it running
3. Code Quality is Low because i am still new with Ai and Lang Chain
4. This project uses a unreleased feature of JDA-5 that Supports User Installable Apps
5. Because it's a unreleased feature, i didn't find any proper command framework, so a workaround manual command registration code was used ( will be fixed in future release )
6. The Ai does not have persistent memory, so it will forget the conversation after restart
7. It's my first time making a docker image, so there might be some issues with it
8. First Response might be slow because of the model loading
## Limitations
1. The Response will vary from model to model
2. URL RAG might not work with smaller models that support less context window
3. Only supports Ollama right now
4. Memory of previous conversation resets on restart> **Note:** Dot Query ( use function to get accurate response ) does not support memory, so it will not work with the previous conversation
## Run Using Docker
_Docker Image is Available at [Docker Hub](https://hub.docker.com/r/zeyoog/ailama)_
### Using Docker Compose :-
#### Docker Compose File :
https://github.com/ZeyoYT/AiLama/blob/0f4dbfabf7440ae73d7019acf3c9fa0b3e74ab1f/docker-compose.yaml#L1-L20#### Run Command :
```
docker-compose up -d
```
### Manual Method :-
#### Pull Command :
```
docker pull zeyoog/ailama
```#### Run Command :
```
docker run -e "TOKEN=" -e OLLAMA_URL= -e OLLAMA_PORT= -e OLLAMA_MODEL= -e OLLAMA_EMBEDDING_MODEL= -e USER_ID= -e "WHITELISTED_USERS=', '" ailama:latest
```
## Build Docker Image Your self
_After Building you can also use the docker compose to run the bot_
__1. Clone Repo and Change Directory :__
```
git clone https://github.com/zeyoyt/AiLama.gitcd AiLama
```__2. Run Docker Build Command :__
```
docker build -t ailama:latest .
```__3. Run Docker Container :__
```
docker run -e "TOKEN=" -e OLLAMA_URL= -e OLLAMA_PORT= -e OLLAMA_MODEL= -e OLLAMA_EMBEDDING_MODEL= -e USER_ID= -e "WHITELISTED_USERS=', '" ailama:latest
```
## SearXNG Guide
_WARNING :- Using SearXNG you are scrapping results of different search engines and it might get you blocked from that search engine as its against there **TOS**_
### Setting SearXNG :-
1. First Install SearXNG ( [Setup Here](https://github.com/searxng/searxng?tab=readme-ov-file#setup) )
2. After Setting SearXNG, Open the `settings.yml` file ( [Guide Here](https://docs.searxng.org/admin/settings/index.html) )
3. Find ` Search: ` ( [Guide Here](https://docs.searxng.org/admin/settings/settings_search.html) )
4. Add ` json ` to ` Formats ` like :-```yaml
# In settings.ymlsearch:
formats:
- html
- json
```### Adding Environment Variables to AiLama :-
1. Add the Following Environment Variables to the `.env` file
```dotenv
SEARXNG_URL=
SEARXNG_PORT=
SEARXNG_ENGINES=
```2. Restart the Bot and Now you can use the Web Search Feature
## List of Commands :-
- /ai
- /web
- /document
- /image
### For More Information on Commands and Usage, Check the [Wiki](https://github.com/zeyoyt/AiLama/wiki)