Compare commits

..

12 Commits

Author SHA1 Message Date
GooeyTuxedo
ba9aeaeb3e Containerize bot and server in one stack. 2023-04-16 11:33:49 -07:00
Raven Scott
7b3e0c1db2 Removing post proceess of output 2023-04-16 16:22:57 +02:00
Raven Scott
5f8e57d121 Adding a space before input. Format: User: message Assistant: message 2023-04-16 14:48:18 +02:00
Raven Scott
cc770e617d fixing prompt 2023-04-16 14:47:04 +02:00
Raven Scott
5a56251e20 Adding cache to server env 2023-04-16 13:22:17 +02:00
Raven Scott
6bb74c8020 update readme 2023-04-12 18:37:02 +02:00
Raven Scott
56c7bfd26d update readme to add screenshot 2023-04-12 18:29:51 +02:00
Raven Scott
5793b7b4ad update readme 2023-04-12 16:32:06 +02:00
Raven Scott
cf6e47eebc update readme 2023-04-12 16:31:29 +02:00
Raven Scott
f98caa23cc update readme 2023-04-12 16:30:59 +02:00
Raven Scott
d3162bce32 dockerize update 2023-04-12 16:19:27 +02:00
Raven Scott
ec7dbde761 dockerize 2023-04-12 16:17:18 +02:00
4 changed files with 31 additions and 14 deletions

View File

@ -32,6 +32,9 @@ Define a generateResponse function that sends a request to the GPT-3 API to gene
Call the generateResponse function within the messageCreate event listener function.
![demo](https://media.discordapp.net/attachments/562897071326101515/1095738407826767922/image.png?width=1038&height=660 "demo")
# Backend REQUIIRED
The HTTP Server from https://abetlen.github.io/llama-cpp-python/ is required to use this bot.
@ -48,7 +51,7 @@ python3 -m llama_cpp.server
Navigate to http://localhost:8000/docs to see the OpenAPI documentation.
# Usage
# Static Usage
1) Use ```npm i ```
@ -60,5 +63,19 @@ Navigate to http://localhost:8000/docs to see the OpenAPI documentation.
6) Run the bot ```node llamabot.js ```
# Docker Compose
This will automatically configure the API for you as well as the bot in two seperate containers within a stack.
1. `git clone https://git.ssh.surf/snxraven/llama-cpp-python-djs-bot.git`
2. `cp default.env .env`
3. Set DATA_DIR in .env to the exact location of your model files.
4. Edit docker-compose.yaml MODEL to ensure the correct model bin is set
5. `docker compose up -d`
Want to make this better? Issue a pull request!

View File

@ -1,5 +1,6 @@
THE_TOKEN = "DISCORD_TOKEN_HERE"
CHANNEL_IDS = 1094494101631680653,1094628334727614605
# ROOT_IP is only used when running the bot without docker compose
ROOT_IP = 192.168.0.15
ROOT_PORT = 8000
DATA_DIR = /home/USERNAME/weights

View File

@ -11,7 +11,7 @@ services:
- ${DATA_DIR}/weights:/usr/src/app/models
environment:
- HOST=llama-python-server
- MODEL=./models/gpt4-x-alpaca-13b-native-4bit-128g.bin
- MODEL=./models/30B.bin
llama-python-djs-bot:
container_name: llama-python-djs-bot
restart: unless-stopped
@ -24,3 +24,4 @@ services:
- CHANNEL_IDS
- ROOT_IP=llama-python-server
- ROOT_PORT=8000
- CACHE=1

View File

@ -104,11 +104,11 @@ client.on('messageCreate', async (message) => {
if (conversation.messages.length === 0) {
conversation.messages.push({
role: 'user',
content: `Your name is rAi, you code, write and provide any information without any mistakes.`
content: ` Assistant name: ChatAI. You code, write and provide any information without any mistakes.`
});
conversation.messages.push({
role: 'user',
content: `My name is ${message.author.username}.`
content: ` User name: ${message.author.username}.`
});
conversation.messages.push({
role: 'assistant',
@ -125,7 +125,7 @@ client.on('messageCreate', async (message) => {
// Append user message to conversation history
conversation.messages.push({
role: 'user',
content: message.cleanContent
content: ` ${message.cleanContent}`
});
try {
@ -190,12 +190,10 @@ async function generateResponse(conversation) {
console.log(JSON.stringify(responseData))
const choice = responseData.choices[0];
// Remove "user None:" and any text after it from the response
const responseText = choice.message.content.trim();
const startIndex = responseText.indexOf('user None:');
const sanitizedResponse = startIndex === -1 ? responseText : responseText.substring(0, startIndex);
const responseText = choice.message.content
return responseText;
return sanitizedResponse;
} catch (err) {
throw err;
} finally {