mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'TavernAI:main' into main
This commit is contained in:
169
colab/GPU.ipynb
169
colab/GPU.ipynb
@@ -1,23 +1,10 @@
|
|||||||
{
|
{
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 0,
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"provenance": []
|
|
||||||
},
|
|
||||||
"kernelspec": {
|
|
||||||
"name": "python3",
|
|
||||||
"display_name": "Python 3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"name": "python"
|
|
||||||
},
|
|
||||||
"accelerator": "GPU",
|
|
||||||
"gpuClass": "standard"
|
|
||||||
},
|
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"id": "d-Yihz3hAb2E"
|
||||||
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"https://colab.research.google.com/github/TavernAI/TavernAI/blob/main/colab/GPU.ipynb<br>\n",
|
"https://colab.research.google.com/github/TavernAI/TavernAI/blob/main/colab/GPU.ipynb<br>\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -47,25 +34,22 @@
|
|||||||
"**Faq**<br>\n",
|
"**Faq**<br>\n",
|
||||||
"* Q: I do not get a TavernAI link\n",
|
"* Q: I do not get a TavernAI link\n",
|
||||||
"* A: It seems the localtunnel service is currently down, so the TavernAI link is unavailable. Need to wait for it to start working again."
|
"* A: It seems the localtunnel service is currently down, so the TavernAI link is unavailable. Need to wait for it to start working again."
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"id": "d-Yihz3hAb2E"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "hCpoIHxYcDGs"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"#@title <-- Tap this if you play on Mobile { display-mode: \"form\" }\n",
|
"#@title <-- Tap this if you play on Mobile { display-mode: \"form\" }\n",
|
||||||
"#Taken from KoboldAI colab\n",
|
"#Taken from KoboldAI colab\n",
|
||||||
"%%html\n",
|
"%%html\n",
|
||||||
"<b>Press play on the music player to keep the tab alive, then start TavernAI below (Uses only 13MB of data)</b><br/>\n",
|
"<b>Press play on the music player to keep the tab alive, then start TavernAI below (Uses only 13MB of data)</b><br/>\n",
|
||||||
"<audio src=\"https://henk.tech/colabkobold/silence.m4a\" controls>"
|
"<audio src=\"https://henk.tech/colabkobold/silence.m4a\" controls>"
|
||||||
],
|
]
|
||||||
"metadata": {
|
|
||||||
"id": "hCpoIHxYcDGs"
|
|
||||||
},
|
|
||||||
"execution_count": null,
|
|
||||||
"outputs": []
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@@ -90,93 +74,9 @@
|
|||||||
"import sys\n",
|
"import sys\n",
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"import threading\n",
|
"import threading\n",
|
||||||
|
"import shutil\n",
|
||||||
"from google.colab import drive\n",
|
"from google.colab import drive\n",
|
||||||
"def copy_chats():\n",
|
|
||||||
" for dirpath, dirnames, filenames in os.walk(\"/content/drive/MyDrive/TavernAI/chats/\"):\n",
|
|
||||||
" for filename in filenames:\n",
|
|
||||||
" source_file = os.path.join(dirpath, filename)\n",
|
|
||||||
" destination_file = source_file.replace(\"/content/drive/MyDrive/TavernAI/chats/\", \"/TavernAIColab/public/chats/\")\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
" if not os.path.exists(destination_file):\n",
|
|
||||||
" if not os.path.exists(os.path.dirname(destination_file)):\n",
|
|
||||||
" os.makedirs(os.path.dirname(destination_file))\n",
|
|
||||||
" !cp -r {source_file} {destination_file}\n",
|
|
||||||
" else:\n",
|
|
||||||
" !cp -r {source_file} {destination_file}\n",
|
|
||||||
" \n",
|
|
||||||
"def copy_characters():\n",
|
|
||||||
" source_files2 = os.listdir(\"/content/drive/MyDrive/TavernAI/characters\")\n",
|
|
||||||
" destination_files2 = os.listdir(\"/TavernAIColab/public/characters/\")\n",
|
|
||||||
"\n",
|
|
||||||
" new_files2 = set(source_files2) - set(destination_files2)\n",
|
|
||||||
" deleted_files2 = set(destination_files2) - set(source_files2)\n",
|
|
||||||
" updated_files2 = [file for file in source_files2 if file in destination_files2 and \n",
|
|
||||||
" os.path.getmtime(f'/content/drive/MyDrive/TavernAI/characters/{file}') > \n",
|
|
||||||
" os.path.getmtime(f'/TavernAIColab/public/characters/{file}')]\n",
|
|
||||||
"\n",
|
|
||||||
" if new_files2:\n",
|
|
||||||
" for file in new_files2:\n",
|
|
||||||
" if os.path.isdir(f'/content/drive/MyDrive/TavernAI/characters/{file}'):\n",
|
|
||||||
" !cp -r /content/drive/MyDrive/TavernAI/characters/{file} /TavernAIColab/public/characters/\n",
|
|
||||||
" else:\n",
|
|
||||||
" !cp /content/drive/MyDrive/TavernAI/characters/{file} /TavernAIColab/public/characters/\n",
|
|
||||||
"\n",
|
|
||||||
" if updated_files2:\n",
|
|
||||||
" for file in updated_files2:\n",
|
|
||||||
" !cp /content/drive/MyDrive/TavernAI/characters/{file} /TavernAIColab/public/characters/\n",
|
|
||||||
" \n",
|
|
||||||
"def sync_files():\n",
|
|
||||||
" while True:\n",
|
|
||||||
" #chats\n",
|
|
||||||
" for dirpath, dirnames, filenames in os.walk(\"/TavernAIColab/public/chats/\"):\n",
|
|
||||||
" for filename in filenames:\n",
|
|
||||||
" source_file = os.path.join(dirpath, filename)\n",
|
|
||||||
" destination_file = source_file.replace(\"/TavernAIColab/public/chats/\", \"/content/drive/MyDrive/TavernAI/chats/\")\n",
|
|
||||||
"\n",
|
|
||||||
" if not os.path.exists(destination_file):\n",
|
|
||||||
" if not os.path.exists(os.path.dirname(destination_file)):\n",
|
|
||||||
" os.makedirs(os.path.dirname(destination_file))\n",
|
|
||||||
" !cp -r {source_file} {destination_file}\n",
|
|
||||||
" elif os.path.getmtime(source_file) > os.path.getmtime(destination_file):\n",
|
|
||||||
" !cp -r {source_file} {destination_file}\n",
|
|
||||||
"\n",
|
|
||||||
" source_files2 = os.listdir(\"/TavernAIColab/public/chats/\")\n",
|
|
||||||
" destination_files2 = os.listdir(\"/content/drive/MyDrive/TavernAI/chats\")\n",
|
|
||||||
"\n",
|
|
||||||
" deleted_files = set(destination_files2) - set(source_files2)\n",
|
|
||||||
" if deleted_files:\n",
|
|
||||||
" for file in deleted_files:\n",
|
|
||||||
" if os.path.isdir(f'/content/drive/MyDrive/TavernAI/chats/{file}'):\n",
|
|
||||||
" !rm -r /content/drive/MyDrive/TavernAI/chats/{file}\n",
|
|
||||||
" else:\n",
|
|
||||||
" !rm /content/drive/MyDrive/TavernAI/chats/{file}\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
" #characters\n",
|
|
||||||
" source_files2 = os.listdir(\"/TavernAIColab/public/characters/\")\n",
|
|
||||||
" destination_files2 = os.listdir(\"/content/drive/MyDrive/TavernAI/characters\")\n",
|
|
||||||
"\n",
|
|
||||||
" new_files2 = set(source_files2) - set(destination_files2)\n",
|
|
||||||
" deleted_files2 = set(destination_files2) - set(source_files2)\n",
|
|
||||||
" updated_files2 = [file for file in source_files2 if file in destination_files2 and \n",
|
|
||||||
" os.path.getmtime(f'/TavernAIColab/public/characters/{file}') > \n",
|
|
||||||
" os.path.getmtime(f'/content/drive/MyDrive/TavernAI/characters/{file}')]\n",
|
|
||||||
"\n",
|
|
||||||
" if new_files2:\n",
|
|
||||||
" for file in new_files2:\n",
|
|
||||||
" if os.path.isdir(f'/taicolabtest/public/characters/{file}'):\n",
|
|
||||||
" !cp -r /TavernAIColab/public/characters/{file} /content/drive/MyDrive/TavernAI/characters\n",
|
|
||||||
" else:\n",
|
|
||||||
" !cp /TavernAIColab/public/characters/{file} /content/drive/MyDrive/TavernAI/characters\n",
|
|
||||||
"\n",
|
|
||||||
" if deleted_files2:\n",
|
|
||||||
" for file in deleted_files2:\n",
|
|
||||||
" !rm /content/drive/MyDrive/TavernAI/characters/{file}\n",
|
|
||||||
"\n",
|
|
||||||
" if updated_files2:\n",
|
|
||||||
" for file in updated_files2:\n",
|
|
||||||
" !cp /TavernAIColab/public/characters/{file} /content/drive/MyDrive/TavernAI/characters\n",
|
|
||||||
" time.sleep(3) \n",
|
|
||||||
" \n",
|
" \n",
|
||||||
"if use_google_drive:\n",
|
"if use_google_drive:\n",
|
||||||
" drive.mount('/content/drive/')\n",
|
" drive.mount('/content/drive/')\n",
|
||||||
@@ -192,6 +92,23 @@
|
|||||||
" if not os.path.exists(\"/content/drive/MyDrive/\"):\n",
|
" if not os.path.exists(\"/content/drive/MyDrive/\"):\n",
|
||||||
" os.mkdir(\"/content/drive/MyDrive/\")\n",
|
" os.mkdir(\"/content/drive/MyDrive/\")\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"def copy_characters(use_google_drive=False):\n",
|
||||||
|
" if not use_google_drive:\n",
|
||||||
|
" return\n",
|
||||||
|
" \n",
|
||||||
|
" src_folder = \"/TavernAIColab/public/characters\"\n",
|
||||||
|
" dst_folder = \"/content/drive/MyDrive/TavernAI/characters\"\n",
|
||||||
|
"\n",
|
||||||
|
" for filename in os.listdir(src_folder):\n",
|
||||||
|
" src_file = os.path.join(src_folder, filename)\n",
|
||||||
|
" dst_file = os.path.join(dst_folder, filename)\n",
|
||||||
|
"\n",
|
||||||
|
" if os.path.exists(dst_file):\n",
|
||||||
|
" print(f\"{dst_file} already exists. Skipping...\")\n",
|
||||||
|
" continue\n",
|
||||||
|
"\n",
|
||||||
|
" shutil.copy(src_file, dst_folder)\n",
|
||||||
|
" print(f\"{src_file} copied to {dst_folder}\")\n",
|
||||||
"Revision = \"\"\n",
|
"Revision = \"\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"if Model == \"Pygmalion 6B\":\n",
|
"if Model == \"Pygmalion 6B\":\n",
|
||||||
@@ -212,6 +129,7 @@
|
|||||||
" tunnel = \"\"\n",
|
" tunnel = \"\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"#Henk's KoboldAI script\n",
|
"#Henk's KoboldAI script\n",
|
||||||
"!wget https://koboldai.org/ckds && chmod +x ckds\n",
|
"!wget https://koboldai.org/ckds && chmod +x ckds\n",
|
||||||
"!./ckds --init only\n",
|
"!./ckds --init only\n",
|
||||||
@@ -238,7 +156,6 @@
|
|||||||
" print(\"Model loading... (It will take 2 - 5 minutes)\")\n",
|
" print(\"Model loading... (It will take 2 - 5 minutes)\")\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
|
||||||
"#TavernAI\n",
|
"#TavernAI\n",
|
||||||
"%cd /\n",
|
"%cd /\n",
|
||||||
"!curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash\n",
|
"!curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash\n",
|
||||||
@@ -246,6 +163,7 @@
|
|||||||
"!nvm use 19.1.0\n",
|
"!nvm use 19.1.0\n",
|
||||||
"!node -v\n",
|
"!node -v\n",
|
||||||
"!git clone https://github.com/TavernAI/TavernAIColab\n",
|
"!git clone https://github.com/TavernAI/TavernAIColab\n",
|
||||||
|
"copy_characters(use_google_drive)\n",
|
||||||
"%cd TavernAIColab\n",
|
"%cd TavernAIColab\n",
|
||||||
"!npm install\n",
|
"!npm install\n",
|
||||||
"time.sleep(1)\n",
|
"time.sleep(1)\n",
|
||||||
@@ -253,15 +171,6 @@
|
|||||||
"%env colaburl=$url\n",
|
"%env colaburl=$url\n",
|
||||||
"!nohup node server.js &\n",
|
"!nohup node server.js &\n",
|
||||||
"time.sleep(3)\n",
|
"time.sleep(3)\n",
|
||||||
"%cd /\n",
|
|
||||||
"copy_characters()\n",
|
|
||||||
"time.sleep(1)\n",
|
|
||||||
"copy_chats()\n",
|
|
||||||
"time.sleep(1)\n",
|
|
||||||
"if use_google_drive:\n",
|
|
||||||
" t = threading.Thread(target=sync_files)\n",
|
|
||||||
" t.daemon = True # Daemonize\n",
|
|
||||||
" t.start()\n",
|
|
||||||
"print('KoboldAI LINK:')\n",
|
"print('KoboldAI LINK:')\n",
|
||||||
"print(url)\n",
|
"print(url)\n",
|
||||||
"print('')\n",
|
"print('')\n",
|
||||||
@@ -269,5 +178,21 @@
|
|||||||
"!lt --port 8000\n"
|
"!lt --port 8000\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"metadata": {
|
||||||
|
"colab": {
|
||||||
|
"provenance": []
|
||||||
|
},
|
||||||
|
"gpuClass": "standard",
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"name": "python"
|
||||||
|
},
|
||||||
|
"accelerator": "GPU"
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 0
|
||||||
}
|
}
|
@@ -3,7 +3,7 @@ Examples of interface and output:
|
|||||||
<br><img src="readme/1.png" height="200" /><img src="readme/4.png" height="200" /><img src="readme/5.png" height="200" />
|
<br><img src="readme/1.png" height="200" /><img src="readme/4.png" height="200" /><img src="readme/5.png" height="200" />
|
||||||
|
|
||||||
[TavernAI Download](https://github.com/TavernAI/TavernAI/archive/refs/heads/main.zip)<br>
|
[TavernAI Download](https://github.com/TavernAI/TavernAI/archive/refs/heads/main.zip)<br>
|
||||||
[TavernAI Run Online](https://colab.research.google.com/github/TavernAI/TavernAI/blob/main/colab/GPU.ipynb)<br><br>
|
[TavernAI Run Online](https://colab.research.google.com/github/TavernAI/TavernAIColab/blob/main/colab/GPU.ipynb)<br><br>
|
||||||
[TavetnAI Boosty](https://boosty.to/tavernai)<br>
|
[TavetnAI Boosty](https://boosty.to/tavernai)<br>
|
||||||
[TavernAI Discord](https://discord.gg/zmK2gmr45t)<br>
|
[TavernAI Discord](https://discord.gg/zmK2gmr45t)<br>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user