Skip to content

Commit

Permalink
Module segmentation and docs update
Browse files Browse the repository at this point in the history
- Cleaned up test files
- Fixed routing
- Documentation update
- Trash Picked Up
- Added search route for web searching
- Fixed requirements
- Shell script returned to replace GUI for `menu.py` because it doesn't work
  • Loading branch information
yukiarimo committed May 7, 2024
1 parent 3df12f5 commit 6a619b8
Show file tree
Hide file tree
Showing 13 changed files with 563 additions and 348 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ static/img/call/*
static/img/art/*
!static/img/art/art_template.png
static/audio/*
!static/audio/README.md
!static/audio/README.md
.DS_Store
133 changes: 108 additions & 25 deletions README.md

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions index.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import shutil
from flask import Flask, get_flashed_messages, request, jsonify, send_from_directory, redirect, url_for, flash
from flask_login import LoginManager, UserMixin, login_required, logout_user, login_user, current_user
from flask_login import LoginManager, UserMixin, login_required, logout_user, login_user, current_user, login_manager
from lib.generate import ChatGenerator, ChatHistoryManager
from lib.router import handle_history_request, handle_image_request, handle_message_request, handle_audio_request, services, about
from lib.router import handle_history_request, handle_image_request, handle_message_request, handle_audio_request, services, about, handle_search_request
from flask_cors import CORS
import json
import os
from itsdangerous import URLSafeTimedSerializer
from flask_login import login_manager
from flask_compress import Compress

with open('static/config.json', 'r') as config_file:
Expand Down Expand Up @@ -94,7 +93,7 @@ def configure_routes(self):
self.app.route('/image', methods=['POST'], endpoint='image')(lambda: handle_image_request(self.chat_history_manager, self))
self.app.route('/audio', methods=['GET', 'POST'], endpoint='audio')(lambda: handle_audio_request(self))
self.app.route('/logout', methods=['GET'])(self.logout)
self.app.route('/search', methods=['POST'])(self.search)
self.app.route('/search', methods=['POST'], endpoint='search')(lambda: handle_search_request(self))

def custom_static(self, filename):
if not filename.startswith('static/') and not filename.startswith('/favicon.ico') and not filename.startswith('/manifest.json'):
Expand Down Expand Up @@ -174,7 +173,6 @@ def flash_messages(self):

@login_required
def yuna_server(self):
# send flash message "Hello, {username}!"
flash(f'Hello, {current_user.get_id()}!')
return send_from_directory('.', 'yuna.html')

Expand Down
321 changes: 321 additions & 0 deletions index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,321 @@
#!/bin/bash

# Function to display a welcome message
info() {
clear
echo "Welcome to Yuna Management Script!"
echo "\n================================"
echo "Yuna is an open source project that aims to create an AI assistant that can help you with your daily tasks."
echo "This script will help you to install the dependencies and models required to run Yuna."
echo "You can read more about Yuna in the documentation in the README.md file."
echo "================================\n"
echo " 1. Go back"

# Read user input
read -p "> " install_choice

case $install_choice in
1) return;;
*) echo "Invalid choice. Please enter a number between 1 and 6.";;
esac
}

# Function to display a goodbye message
goodbye() {
echo "Thank you for using Yuna Management Script. Goodbye!"
}

# Function to start Yuna
start_yuna() {
echo "Starting Yuna..."
python index.py
}

# Function to Dependencies Setup
install_update_dependencies() {
clear
while true; do
echo "========== Installation... =========="
echo "1. CPU"
echo "2. NVIDIA GPU"
echo "3. AMD GPU"
echo "4. Metal"
echo "5. Go back"

read -p "> " install_choice

case $install_choice in
1) install_cpu;;
2) install_nvidia;;
3) install_amd;;
4.) install_metal;;
5) return;;
*) echo "Invalid choice. Please enter a number between 1 and 5.";;
esac
done
}

install_cpu() {
echo "Installing CPU dependencies..."
pip install -r requirements.txt --break-system-packages
echo "CPU dependencies installed."

}

install_nvidia() {
echo "Installing NVIDIA dependencies..."
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
pip install -r requirements-nvidia.txt --break-system-packages
echo "NVIDIA dependencies installed."

}

install_amd() {
echo "Installing AMD dependencies..."
# YOU NEED TO SPECIFY THE CORRECT GFX NUMBER FOR YOUR GPU
# THE DEFAULT IS GFX1100 - which was used since I have a RX7600
# Check the Shader ISA Instruction Set for your GPU
CMAKE_ARGS="-DLLAMA_HIPBLAS=ON -DCMAKE_C_COMPILER=/opt/rocm/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ -DCMAKE_PREFIX_PATH=/opt/rocm -DAMDGPU_TARGETS=gfx1100" FORCE_CMAKE=1 pip install llama-cpp-python
CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
pip install -r requirements-amd.txt --break-system-packages
echo "AMD dependencies installed."

}

install_metal() {
echo "Installing Metal dependencies..."
CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
pip install -r requirements-macos.txt --break-system-packages
echo "Metal dependencies installed."

}


# Submenu for configure()
configure_submenu() {
while true; do
clear

echo "========== Configure Project Menu =========="
echo "1. Install models"
echo "2. Clear models"
echo "3. Dependencies Setup"
echo "4. Info"
echo "5. Go back"

# Read user input
read -p "> " config_choice

# Execute the corresponding function based on user input
case $config_choice in
1) install_models;;
2) clear_models;;
3) install_update_dependencies;;
4) info;;
5) break;; # Go back
*) echo "Invalid choice. Please enter a number between 1 and 5.";;
esac

# Add a newline for better readability
echo
done
}

# Function to install models
install_models() {
clear
echo "========== Install Models Menu =========="
echo " 1. All"
echo " 2. All AGI"
echo " 3. Vision"
echo " 4. Art"
echo " 5. Emotion"
echo " 6. Talk"
echo " 7. Yuna"
echo " 8. Go back"
echo " 9. Exit"

# Read user input
read -p "Enter your choice (1-6): " install_choice

case $install_choice in
1) install_all_models;;
2) install_all_agi_models;;
3) install_vision_model;;
4) install_art_model;;
5) install_emotion_model;;
6) install_talk_model;;
7) install_yuna_model;;
8) return;;
9) goodbye; exit;;
*) echo "Invalid choice. Please enter a number between 1 and 6.";;
esac
}

# Function to install all models
install_all_models() {
install_all_agi_models
install_yuna_model
}

# Function to install all AGI models
install_all_agi_models() {
echo "Installing all AGI models..."
install_vision_model
install_art_model
install_emotion_model
}

# Function to install Vision model
install_vision_model() {
echo "Installing Vision model..."
git clone https://huggingface.co/yukiarimo/yuna-vision lib/models/agi/yuna-vision/
}

# Function to install Art model
install_art_model() {
echo "Installing Art model..."
wget https://huggingface.co/yukiarimo/anyloli/resolve/main/any_loli.safetensors -P lib/models/agi/art/
}

# Function to install Vision model
install_emotion_model() {
echo "Installing Vision model..."
git clone https://huggingface.co/yukiarimo/yuna-emotion lib/models/agi/yuna-emotion/
}

install_talk_model() {
echo "Installing Talk Model"
git clone https://huggingface.co/yukiarimo/yuna-talk lib/models/agi/yuna-talk/
}

# Function to install Yuna model
install_yuna_model() {
echo "Installing Yuna model..."
wget https://huggingface.co/yukiarimo/yuna-ai-v3/resolve/main/yuna-ai-v3-q6_k.gguf -P lib/models/yuna/
}

# Function to clear models
clear_models() {
clear
echo "========== Clear Models Menu =========="
echo "This will delete all models inside 'lib/models/'."
read -p "Do you want to proceed? (y/n): " confirm_clear

case $confirm_clear in
[Yy])
echo "Clearing models..."
rm -rf lib/models/*
echo "Models cleared."
;;
[Nn])
echo "Operation canceled. No models were cleared."
;;
*)
echo "Invalid choice. Please enter 'y' or 'n'."
;;
esac
}

oneClickInstall() {
install_update_dependencies
install_models

read -p "Do you want to start Yuna? (y/n): " confirm_start

case $confirm_start in
[Yy])
start_yuna
;;
[Nn])
echo "Operation canceled. Everything is installed."
;;
*)
echo "Invalid choice. Please enter 'y' or 'n'."
;;
esac
}

contribute() {
clear
echo "========== Contribute to Yuna =========="
echo "Yuna is an open source project. The following commands will help you to contribute to Yuna."
echo "git fetch origin main\ngit merge main\ngit push origin dev:main\n"
echo "Do you want to proceed? (y/n): " confirm_contribute

case $confirm_contribute in
[Yy])
echo "Contribute to Yuna..."
git fetch origin main
git merge main
git push origin dev:main
echo "Contribute to Yuna done."
;;
[Nn])
echo "Operation canceled. No contribution was made."
;;
*)
echo "Invalid choice. Please enter 'y' or 'n'."
;;
esac
}

donate() {
clear
echo "========== Donate =========="
echo "Yuna is an open source project. You can support the development of Yuna by donating."
echo "1. https://www.patreon.com/YukiArimo"
echo "2. https://ko-fi.com/yukiarimo"
echo "3. https://www.buymeacoffee.com/yukiarimo"
echo "4. Go back"

read -p "Enter your choice (1-4): " donate_choice

case $donate_choice in
1) xdg-open https://www.patreon.com/YukiArimo;;
2) xdg-open https://ko-fi.com/yukiarimo;;
3) xdg-open https://www.buymeacoffee.com/yukiarimo;;
4) return;;
*) echo "Invalid choice. Please enter a number between 1 and 2.";;
esac
}

# Display the main menu
while true; do
clear
echo """
██ ██ ██ ██ ███ ██ ███████   ███████ ██
██ ██ ██ ██ ████ ██ ██ ██   ██ ██ ██
████ ██ ██ ██ ██ ██ ███████   ███████ ██
██ ██ ██ ██ ████ ██ ██   ██ ██ ██
██ ████████ ██ ███ ██ ██   ██ ██ ██
"""
echo "========== Main Menu =========="
echo "1. Start Yuna"
echo "2. Dependencies Setup"
echo "3. One click install"
echo "4. Configure Project"
echo "5. Contribute to Yuna"
echo "6. Info"
echo "7. Donate"
echo "8. Exit"

# Read user input
read -p "> " choice

# Execute the corresponding function based on user input
case $choice in
1) start_yuna;;
2) install_update_dependencies;;
3) oneClickInstall;;
4) configure_submenu;;
5) contribute;;
6) info;;
7) donate;;
8) goodbye; exit;;
*) echo "Invalid choice. Please enter a number between 1 and 5.";;
esac

# Add a newline for better readability.
echo
done
Loading

0 comments on commit 6a619b8

Please sign in to comment.